Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions examples/jsm/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.' );

}

Expand All @@ -175,15 +175,15 @@ 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.' );

}

const degree = SH_DEGREE_TO_COMPONENTS.indexOf( restComponentCount );

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 }).` );

}

Expand Down Expand Up @@ -267,21 +267,21 @@ 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.' );

}

const count = position.count;

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.' );

}

Expand Down Expand Up @@ -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.' );

}

Expand Down Expand Up @@ -383,4 +383,4 @@ function writeSphericalHarmonicsFromRest( sphericalHarmonicsBytes, index, shRest

}

export { PLYGaussianSplatLoader };
export { GaussianSplatPLYLoader };
2 changes: 1 addition & 1 deletion examples/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ],
Expand Down
24 changes: 14 additions & 10 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -554,8 +560,6 @@ class WebGLRenderer {

}

initGLContext();

// initialize internal render target for non-UnsignedByteType color buffer

if ( _outputBufferType !== UnsignedByteType ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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(
Expand All @@ -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 ]] ) {

Expand All @@ -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 ) ),
Expand All @@ -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 ),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/three.addons.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down