diff --git a/examples/files.json b/examples/files.json index 0f28782c997e8c..e67c9ac04f3979 100644 --- a/examples/files.json +++ b/examples/files.json @@ -347,7 +347,7 @@ "webgpu_equirectangular", "webgpu_fog_height", "webgpu_furnace_test", - "webgpu_gaussian_splatting", + "webgpu_gaussian_splat", "webgpu_generator_building", "webgpu_generator_city", "webgpu_geometry_loft", diff --git a/examples/jsm/loaders/FBXLoader.js b/examples/jsm/loaders/FBXLoader.js index 44302ecbca4927..411d99b8cbd632 100644 --- a/examples/jsm/loaders/FBXLoader.js +++ b/examples/jsm/loaders/FBXLoader.js @@ -1017,6 +1017,7 @@ class FBXTreeParser { if ( sceneGraph.children.length === 1 && sceneGraph.children[ 0 ].isGroup ) { sceneGraph.children[ 0 ].animations = animations; + Object.assign( sceneGraph.children[ 0 ].userData, sceneGraph.userData ); sceneGraph = sceneGraph.children[ 0 ]; } diff --git a/examples/jsm/loaders/PLYGaussianSplatLoader.js b/examples/jsm/loaders/GaussianSplatPLYLoader.js similarity index 93% rename from examples/jsm/loaders/PLYGaussianSplatLoader.js rename to examples/jsm/loaders/GaussianSplatPLYLoader.js index 7d60c425992186..4db2368f853510 100644 --- a/examples/jsm/loaders/PLYGaussianSplatLoader.js +++ b/examples/jsm/loaders/GaussianSplatPLYLoader.js @@ -54,15 +54,15 @@ const _restPropertyPattern = /^f_rest_\d+$/; * Gaussian splat geometry. * * ```js - * const loader = new PLYGaussianSplatLoader(); + * const loader = new GaussianSplatPLYLoader(); * const geometry = await loader.loadAsync( './models/gsplat/point_cloud.ply' ); * scene.add( new GaussianSplatMesh( geometry ) ); * ``` * * @augments Loader - * @three_import import { PLYGaussianSplatLoader } from 'three/addons/loaders/PLYGaussianSplatLoader.js'; + * @three_import import { GaussianSplatPLYLoader } from 'three/addons/loaders/GaussianSplatPLYLoader.js'; */ -class PLYGaussianSplatLoader extends Loader { +class GaussianSplatPLYLoader extends Loader { /** * Constructs a new Gaussian splat PLY loader. @@ -154,7 +154,7 @@ function detectSphericalHarmonicsDegree( data ) { if ( headerMatch === null ) { - throw new Error( 'THREE.PLYGaussianSplatLoader: Missing PLY header.' ); + throw new Error( 'THREE.GaussianSplatPLYLoader: Missing PLY header.' ); } @@ -175,7 +175,7 @@ function detectSphericalHarmonicsDegree( data ) { if ( REQUIRED_PLY_PROPERTIES.some( name => ! propertyNames.has( name ) ) ) { - throw new Error( 'THREE.PLYGaussianSplatLoader: PLY file requires position, scale, rotation, f_dc and opacity properties.' ); + throw new Error( 'THREE.GaussianSplatPLYLoader: PLY file requires position, scale, rotation, f_dc and opacity properties.' ); } @@ -183,7 +183,7 @@ function detectSphericalHarmonicsDegree( data ) { if ( degree === - 1 ) { - throw new Error( `THREE.PLYGaussianSplatLoader: Unsupported number of f_rest spherical harmonics coefficients (${ restComponentCount }).` ); + throw new Error( `THREE.GaussianSplatPLYLoader: Unsupported number of f_rest spherical harmonics coefficients (${ restComponentCount }).` ); } @@ -267,7 +267,7 @@ function convertPLYGeometry( geometry ) { if ( position === undefined || scale === undefined || rotation === undefined || sh0 === undefined || opacity === undefined ) { - throw new Error( 'THREE.PLYGaussianSplatLoader: PLY file requires position, scale, rotation, f_dc and opacity properties.' ); + throw new Error( 'THREE.GaussianSplatPLYLoader: PLY file requires position, scale, rotation, f_dc and opacity properties.' ); } @@ -275,13 +275,13 @@ function convertPLYGeometry( geometry ) { if ( position.itemSize !== 3 || scale.itemSize !== 3 || rotation.itemSize !== 4 || sh0.itemSize !== 3 || opacity.itemSize !== 1 ) { - throw new Error( 'THREE.PLYGaussianSplatLoader: Invalid Gaussian splat PLY property itemSize.' ); + throw new Error( 'THREE.GaussianSplatPLYLoader: Invalid Gaussian splat PLY property itemSize.' ); } if ( scale.count !== count || rotation.count !== count || sh0.count !== count || opacity.count !== count ) { - throw new Error( 'THREE.PLYGaussianSplatLoader: Gaussian splat PLY property counts must match position.' ); + throw new Error( 'THREE.GaussianSplatPLYLoader: Gaussian splat PLY property counts must match position.' ); } @@ -347,7 +347,7 @@ function getRestSphericalHarmonicsDegree( shRest ) { if ( degree === - 1 ) { - throw new Error( 'THREE.PLYGaussianSplatLoader: Unsupported number of f_rest spherical harmonics coefficients.' ); + throw new Error( 'THREE.GaussianSplatPLYLoader: Unsupported number of f_rest spherical harmonics coefficients.' ); } @@ -383,4 +383,4 @@ function writeSphericalHarmonicsFromRest( sphericalHarmonicsBytes, index, shRest } -export { PLYGaussianSplatLoader }; +export { GaussianSplatPLYLoader }; diff --git a/examples/screenshots/webgpu_gaussian_splatting.jpg b/examples/screenshots/webgpu_gaussian_splat.jpg similarity index 100% rename from examples/screenshots/webgpu_gaussian_splatting.jpg rename to examples/screenshots/webgpu_gaussian_splat.jpg diff --git a/examples/tags.json b/examples/tags.json index fbefb8a6fc22e9..60d8e977a47f35 100644 --- a/examples/tags.json +++ b/examples/tags.json @@ -31,7 +31,7 @@ "webgl_geometry_colors_lookuptable": [ "vertex" ], "webgl_geometry_csg": [ "community", "csg", "bvh", "constructive", "solid", "geometry", "games", "level" ], "webgpu_geometry_loft": [ "sweep", "skin", "sections", "surface", "tsl", "procedural" ], - "webgpu_gaussian_splatting": [ "splat", "point cloud", "loader", "compute", "tsl" ], + "webgpu_gaussian_splat": [ "splatting", "point cloud", "loader", "compute", "tsl" ], "webgl_geometry_nurbs": [ "curve", "surface" ], "webgl_geometry_spline_editor": [ "curve" ], "webgl_geometry_terrain": [ "fog" ], diff --git a/examples/webgpu_gaussian_splatting.html b/examples/webgpu_gaussian_splat.html similarity index 100% rename from examples/webgpu_gaussian_splatting.html rename to examples/webgpu_gaussian_splat.html diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index c15b688a9b95f5..a86234d1f0bd53 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -375,6 +375,14 @@ class WebGLRenderer { } + let extensions, capabilities, state, info; + let properties, textures, environments, attributes, geometries, objects; + let programCache, materials, renderLists, renderStates, clipping, shadowMap; + + let background, morphtargets, bufferRenderer, indexedBufferRenderer; + + let utils, bindingStates, uniformsGroups; + try { const contextAttributes = { @@ -418,21 +426,19 @@ class WebGLRenderer { } + initGLContext(); + } catch ( e ) { + canvas.removeEventListener( 'webglcontextlost', onContextLost, false ); + canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false ); + canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false ); + error( 'WebGLRenderer: ' + e.message ); throw e; } - let extensions, capabilities, state, info; - let properties, textures, environments, attributes, geometries, objects; - let programCache, materials, renderLists, renderStates, clipping, shadowMap; - - let background, morphtargets, bufferRenderer, indexedBufferRenderer; - - let utils, bindingStates, uniformsGroups; - function initGLContext() { extensions = new WebGLExtensions( _gl ); @@ -554,8 +560,6 @@ class WebGLRenderer { } - initGLContext(); - // initialize internal render target for non-UnsignedByteType color buffer if ( _outputBufferType !== UnsignedByteType ) { diff --git a/test/unit/addons/loaders/PLYGaussianSplatLoader.tests.js b/test/unit/addons/loaders/GaussianSplatPLYLoader.tests.js similarity index 90% rename from test/unit/addons/loaders/PLYGaussianSplatLoader.tests.js rename to test/unit/addons/loaders/GaussianSplatPLYLoader.tests.js index 00798be1e67de6..9599dd6c28a398 100644 --- a/test/unit/addons/loaders/PLYGaussianSplatLoader.tests.js +++ b/test/unit/addons/loaders/GaussianSplatPLYLoader.tests.js @@ -1,6 +1,6 @@ import { BufferGeometry } from 'three'; -import { PLYGaussianSplatLoader } from '../../../../examples/jsm/loaders/PLYGaussianSplatLoader.js'; +import { GaussianSplatPLYLoader } from '../../../../examples/jsm/loaders/GaussianSplatPLYLoader.js'; import { unpackSphericalHarmonicsBand } from '../utils/GaussianSplatTestUtils.js'; const EPS = 1e-6; @@ -65,11 +65,11 @@ export default QUnit.module( 'Addons', () => { QUnit.module( 'Loaders', () => { - QUnit.module( 'PLYGaussianSplatLoader', () => { + QUnit.module( 'GaussianSplatPLYLoader', () => { QUnit.test( 'parses a Gaussian splat PLY with no spherical harmonics', ( assert ) => { - const loader = new PLYGaussianSplatLoader(); + const loader = new GaussianSplatPLYLoader(); const data = loader.parse( createGaussianSplatPLY() ); const covariances = data.getAttribute( 'covariance' ).array; @@ -84,7 +84,7 @@ export default QUnit.module( 'Addons', () => { QUnit.test( 'detects spherical harmonics degree from the header and converts f_rest', ( assert ) => { - const loader = new PLYGaussianSplatLoader(); + const loader = new GaussianSplatPLYLoader(); const data = loader.parse( createGaussianSplatPLY( 9 ) ); assert.deepEqual( @@ -97,7 +97,7 @@ export default QUnit.module( 'Addons', () => { QUnit.test( 'requires no pre-setup for each supported spherical harmonics degree', ( assert ) => { - const loader = new PLYGaussianSplatLoader(); + const loader = new GaussianSplatPLYLoader(); for ( const [ degree, count ] of [[ 0, 0 ], [ 1, 9 ], [ 2, 24 ], [ 3, 45 ]] ) { @@ -110,7 +110,7 @@ export default QUnit.module( 'Addons', () => { QUnit.test( 'rejects an unsupported number of f_rest coefficients', ( assert ) => { - const loader = new PLYGaussianSplatLoader(); + const loader = new GaussianSplatPLYLoader(); assert.throws( () => loader.parse( createGaussianSplatPLY( 5 ) ), @@ -133,7 +133,7 @@ export default QUnit.module( 'Addons', () => { '1 2 3' ].join( '\n' ); - const loader = new PLYGaussianSplatLoader(); + const loader = new GaussianSplatPLYLoader(); assert.throws( () => loader.parse( ply ), diff --git a/test/unit/three.addons.unit.js b/test/unit/three.addons.unit.js index ec36511f48a17a..8f5d15137d5f11 100644 --- a/test/unit/three.addons.unit.js +++ b/test/unit/three.addons.unit.js @@ -9,7 +9,7 @@ import './addons/loaders/FBXLoader.tests.js'; import './addons/loaders/GLTFLoader.tests.js'; import './addons/loaders/HDRLoader.tests.js'; import './addons/loaders/KSPLATLoader.tests.js'; -import './addons/loaders/PLYGaussianSplatLoader.tests.js'; +import './addons/loaders/GaussianSplatPLYLoader.tests.js'; import './addons/loaders/SPLATLoader.tests.js'; import './addons/loaders/SPZLoader.tests.js'; import './addons/loaders/USDLoader.tests.js';