@@ -450,9 +450,9 @@ GaussianSplatPrimitive.transformTile = function (tile) {
450450 computedModelMatrix ,
451451 scratchMatrix4A ,
452452 ) ;
453- const positions = tile . content . _originalPositions ;
454- const rotations = tile . content . _originalRotations ;
455- const scales = tile . content . _originalScales ;
453+ const positions = tile . content . positions ;
454+ const rotations = tile . content . rotations ;
455+ const scales = tile . content . scales ;
456456 const attributePositions = ModelUtility . getAttributeBySemantic (
457457 gltfPrimitive ,
458458 VertexAttributeSemantic . POSITION ,
@@ -471,19 +471,19 @@ GaussianSplatPrimitive.transformTile = function (tile) {
471471 const position = new Cartesian3 ( ) ;
472472 const rotation = new Quaternion ( ) ;
473473 const scale = new Cartesian3 ( ) ;
474- for ( let i = 0 ; i < positions . length / 3 ; ++ i ) {
475- position . x = positions [ i * 3 ] ;
476- position . y = positions [ i * 3 + 1 ] ;
477- position . z = positions [ i * 3 + 2 ] ;
474+ for ( let i = 0 ; i < attributePositions . length / 3 ; ++ i ) {
475+ position . x = attributePositions [ i * 3 ] ;
476+ position . y = attributePositions [ i * 3 + 1 ] ;
477+ position . z = attributePositions [ i * 3 + 2 ] ;
478478
479- rotation . x = rotations [ i * 4 ] ;
480- rotation . y = rotations [ i * 4 + 1 ] ;
481- rotation . z = rotations [ i * 4 + 2 ] ;
482- rotation . w = rotations [ i * 4 + 3 ] ;
479+ rotation . x = attributeRotations [ i * 4 ] ;
480+ rotation . y = attributeRotations [ i * 4 + 1 ] ;
481+ rotation . z = attributeRotations [ i * 4 + 2 ] ;
482+ rotation . w = attributeRotations [ i * 4 + 3 ] ;
483483
484- scale . x = scales [ i * 3 ] ;
485- scale . y = scales [ i * 3 + 1 ] ;
486- scale . z = scales [ i * 3 + 2 ] ;
484+ scale . x = attributeScales [ i * 3 ] ;
485+ scale . y = attributeScales [ i * 3 + 1 ] ;
486+ scale . z = attributeScales [ i * 3 + 2 ] ;
487487
488488 Matrix4 . fromTranslationQuaternionRotationScale (
489489 position ,
@@ -498,18 +498,18 @@ GaussianSplatPrimitive.transformTile = function (tile) {
498498 Matrix4 . getRotation ( scratchMatrix4C , rotation ) ;
499499 Matrix4 . getScale ( scratchMatrix4C , scale ) ;
500500
501- attributePositions [ i * 3 ] = position . x ;
502- attributePositions [ i * 3 + 1 ] = position . y ;
503- attributePositions [ i * 3 + 2 ] = position . z ;
501+ positions [ i * 3 ] = position . x ;
502+ positions [ i * 3 + 1 ] = position . y ;
503+ positions [ i * 3 + 2 ] = position . z ;
504504
505- attributeRotations [ i * 4 ] = rotation . x ;
506- attributeRotations [ i * 4 + 1 ] = rotation . y ;
507- attributeRotations [ i * 4 + 2 ] = rotation . z ;
508- attributeRotations [ i * 4 + 3 ] = rotation . w ;
505+ rotations [ i * 4 ] = rotation . x ;
506+ rotations [ i * 4 + 1 ] = rotation . y ;
507+ rotations [ i * 4 + 2 ] = rotation . z ;
508+ rotations [ i * 4 + 3 ] = rotation . w ;
509509
510- attributeScales [ i * 3 ] = scale . x ;
511- attributeScales [ i * 3 + 1 ] = scale . y ;
512- attributeScales [ i * 3 + 2 ] = scale . z ;
510+ scales [ i * 3 ] = scale . x ;
511+ scales [ i * 3 + 1 ] = scale . y ;
512+ scales [ i * 3 + 2 ] = scale . z ;
513513 }
514514} ;
515515
@@ -860,21 +860,27 @@ GaussianSplatPrimitive.prototype.update = function (frameState) {
860860 const aggregateAttributeValues = (
861861 componentDatatype ,
862862 getAttributeCallback ,
863+ numberOfComponents ,
863864 ) => {
864865 let aggregate ;
865866 let offset = 0 ;
866867 for ( const tile of tiles ) {
867- const primitive = tile . content . gltfPrimitive ;
868- const attribute = getAttributeCallback ( primitive ) ;
868+ const content = tile . content ;
869+ const attribute = getAttributeCallback ( content ) ;
870+ const componentsPerAttribute = defined ( numberOfComponents )
871+ ? numberOfComponents
872+ : AttributeType . getNumberOfComponents ( attribute . type ) ;
873+ const buffer = defined ( attribute . typedArray )
874+ ? attribute . typedArray
875+ : attribute ;
869876 if ( ! defined ( aggregate ) ) {
870877 aggregate = ComponentDatatype . createTypedArray (
871878 componentDatatype ,
872- totalElements *
873- AttributeType . getNumberOfComponents ( attribute . type ) ,
879+ totalElements * componentsPerAttribute ,
874880 ) ;
875881 }
876- aggregate . set ( attribute . typedArray , offset ) ;
877- offset += attribute . typedArray . length ;
882+ aggregate . set ( buffer , offset ) ;
883+ offset += buffer . length ;
878884 }
879885 return aggregate ;
880886 } ;
@@ -906,36 +912,27 @@ GaussianSplatPrimitive.prototype.update = function (frameState) {
906912
907913 this . _positions = aggregateAttributeValues (
908914 ComponentDatatype . FLOAT ,
909- ( gltfPrimitive ) =>
910- ModelUtility . getAttributeBySemantic (
911- gltfPrimitive ,
912- VertexAttributeSemantic . POSITION ,
913- ) ,
915+ ( content ) => content . positions ,
916+ 3 ,
914917 ) ;
915918
916919 this . _scales = aggregateAttributeValues (
917920 ComponentDatatype . FLOAT ,
918- ( gltfPrimitive ) =>
919- ModelUtility . getAttributeBySemantic (
920- gltfPrimitive ,
921- VertexAttributeSemantic . SCALE ,
922- ) ,
921+ ( content ) => content . scales ,
922+ 3 ,
923923 ) ;
924924
925925 this . _rotations = aggregateAttributeValues (
926926 ComponentDatatype . FLOAT ,
927- ( gltfPrimitive ) =>
928- ModelUtility . getAttributeBySemantic (
929- gltfPrimitive ,
930- VertexAttributeSemantic . ROTATION ,
931- ) ,
927+ ( content ) => content . rotations ,
928+ 4 ,
932929 ) ;
933930
934931 this . _colors = aggregateAttributeValues (
935932 ComponentDatatype . UNSIGNED_BYTE ,
936- ( gltfPrimitive ) =>
933+ ( content ) =>
937934 ModelUtility . getAttributeBySemantic (
938- gltfPrimitive ,
935+ content . gltfPrimitive ,
939936 VertexAttributeSemantic . COLOR ,
940937 ) ,
941938 ) ;
0 commit comments