@@ -72,7 +72,7 @@ export class Viewer {
7272 // Tells the viewer to pretend the device pixel ratio is 1, which can boost performance on devices where it is larger,
7373 // at a small cost to visual quality
7474 this . ignoreDevicePixelRatio = options . ignoreDevicePixelRatio || false ;
75- this . devicePixelRatio = this . ignoreDevicePixelRatio ? 1 : window . devicePixelRatio ;
75+ this . devicePixelRatio = this . ignoreDevicePixelRatio ? 1 : ( window . devicePixelRatio || 1 ) ;
7676
7777 // Tells the viewer to use 16-bit floating point values when storing splat covariance data in textures, instead of 32-bit
7878 this . halfPrecisionCovariancesOnGPU = options . halfPrecisionCovariancesOnGPU || false ;
@@ -117,6 +117,9 @@ export class Viewer {
117117 // https://github.com/graphdeco-inria/gaussian-splatting/issues/294#issuecomment-1772688093
118118 this . antialiased = options . antialiased || false ;
119119
120+ // This constant is added to the projected 2D screen-space splat scales
121+ this . kernel2DSize = ( options . kernel2DSize === undefined ) ? 0.3 : options . kernel2DSize ;
122+
120123 this . webXRMode = options . webXRMode || WebXRMode . None ;
121124 if ( this . webXRMode !== WebXRMode . None ) {
122125 this . gpuAcceleratedSort = false ;
@@ -286,7 +289,7 @@ export class Viewer {
286289 this . splatMesh = new SplatMesh ( this . splatRenderMode , this . dynamicScene , this . enableOptionalEffects ,
287290 this . halfPrecisionCovariancesOnGPU , this . devicePixelRatio , this . gpuAcceleratedSort ,
288291 this . integerBasedSort , this . antialiased , this . maxScreenSpaceSplatSize , this . logLevel ,
289- this . sphericalHarmonicsDegree , this . sceneFadeInRateMultiplier ) ;
292+ this . sphericalHarmonicsDegree , this . sceneFadeInRateMultiplier , this . kernel2DSize ) ;
290293 this . splatMesh . frustumCulled = false ;
291294 if ( this . onSplatMeshChangedCallback ) this . onSplatMeshChangedCallback ( ) ;
292295 }
@@ -303,7 +306,7 @@ export class Viewer {
303306 this . rootElement . style . position = 'absolute' ;
304307 document . body . appendChild ( this . rootElement ) ;
305308 } else {
306- this . rootElement = this . renderer . domElement . parentElement || document . body ;
309+ this . rootElement = this . renderer . domElement || document . body ;
307310 }
308311 }
309312
@@ -725,6 +728,7 @@ export class Viewer {
725728 *
726729 * onProgress: Function to be called as file data are received, or other processing occurs
727730 *
731+ * headers: Optional HTTP headers to be sent along with splat requests
728732 * }
729733 * @return {AbortablePromise }
730734 */
@@ -819,7 +823,8 @@ export class Viewer {
819823
820824 const loadFunc = progressiveLoad ? this . downloadAndBuildSingleSplatSceneProgressiveLoad . bind ( this ) :
821825 this . downloadAndBuildSingleSplatSceneStandardLoad . bind ( this ) ;
822- return loadFunc ( path , format , options . splatAlphaRemovalThreshold , buildSection . bind ( this ) , onProgress , hideLoadingUI . bind ( this ) ) ;
826+ return loadFunc ( path , format , options . splatAlphaRemovalThreshold , buildSection . bind ( this ) ,
827+ onProgress , hideLoadingUI . bind ( this ) , options . headers ) ;
823828 }
824829
825830 /**
@@ -832,12 +837,13 @@ export class Viewer {
832837 * @param {function } buildFunc Function to build the viewer's splat mesh with the downloaded splat buffer
833838 * @param {function } onProgress Function to be called as file data are received, or other processing occurs
834839 * @param {function } onException Function to be called when exception occurs
840+ * @param {object } headers Optional HTTP headers to pass to use for downloading splat scene
835841 * @return {AbortablePromise }
836842 */
837- downloadAndBuildSingleSplatSceneStandardLoad ( path , format , splatAlphaRemovalThreshold , buildFunc , onProgress , onException ) {
843+ downloadAndBuildSingleSplatSceneStandardLoad ( path , format , splatAlphaRemovalThreshold , buildFunc , onProgress , onException , headers ) {
838844
839- const downloadPromise = this . downloadSplatSceneToSplatBuffer ( path , splatAlphaRemovalThreshold ,
840- onProgress , false , undefined , format ) ;
845+ const downloadPromise = this . downloadSplatSceneToSplatBuffer ( path , splatAlphaRemovalThreshold , onProgress , false ,
846+ undefined , format , headers ) ;
841847 const downloadAndBuildPromise = abortablePromiseWithExtractedComponents ( downloadPromise . abortHandler ) ;
842848
843849 downloadPromise . then ( ( splatBuffer ) => {
@@ -871,10 +877,11 @@ export class Viewer {
871877 * @param {function } buildFunc Function to rebuild the viewer's splat mesh after a new splat buffer section is downloaded
872878 * @param {function } onDownloadProgress Function to be called as file data are received
873879 * @param {function } onDownloadException Function to be called when exception occurs at any point during the full download
880+ * @param {object } headers Optional HTTP headers to pass to use for downloading splat scene
874881 * @return {AbortablePromise }
875882 */
876883 downloadAndBuildSingleSplatSceneProgressiveLoad ( path , format , splatAlphaRemovalThreshold , buildFunc ,
877- onDownloadProgress , onDownloadException ) {
884+ onDownloadProgress , onDownloadException , headers ) {
878885 let progressiveLoadedSectionBuildCount = 0 ;
879886 let progressiveLoadedSectionBuilding = false ;
880887 const queuedProgressiveLoadSectionBuilds = [ ] ;
@@ -917,7 +924,7 @@ export class Viewer {
917924 } ;
918925
919926 const splatSceneDownloadPromise = this . downloadSplatSceneToSplatBuffer ( path , splatAlphaRemovalThreshold , onDownloadProgress , true ,
920- onProgressiveLoadSectionProgress , format ) ;
927+ onProgressiveLoadSectionProgress , format , headers ) ;
921928
922929 const progressiveLoadFirstSectionBuildPromise = abortablePromiseWithExtractedComponents ( splatSceneDownloadPromise . abortHandler ) ;
923930 const splatSceneDownloadAndBuildPromise = abortablePromiseWithExtractedComponents ( ) ;
@@ -953,6 +960,11 @@ export class Viewer {
953960 * rotation (Array<number>): Rotation of the scene represented as a quaternion, defaults to [0, 0, 0, 1]
954961 *
955962 * scale (Array<number>): Scene's scale, defaults to [1, 1, 1]
963+ *
964+ * headers: Optional HTTP headers to be sent along with splat requests
965+ *
966+ * format (SceneFormat) Optional, the format of the scene data (.ply, .ksplat, .splat). If not present, the
967+ * file extension in 'path' will be used to determine the format (if it is present)
956968 * }
957969 * @param {boolean } showLoadingUI Display a loading spinner while the scene is loading, defaults to true
958970 * @param {function } onProgress Function to be called as file data are received
@@ -998,7 +1010,8 @@ export class Viewer {
9981010 const options = sceneOptions [ i ] ;
9991011 const format = ( options . format !== undefined && options . format !== null ) ? options . format : sceneFormatFromPath ( options . path ) ;
10001012 const baseDownloadPromise = this . downloadSplatSceneToSplatBuffer ( options . path , options . splatAlphaRemovalThreshold ,
1001- onLoadProgress . bind ( this , i ) , false , undefined , format ) ;
1013+ onLoadProgress . bind ( this , i ) , false , undefined ,
1014+ format , options . headers ) ;
10021015 baseDownloadPromises . push ( baseDownloadPromise ) ;
10031016 nativeDownloadPromises . push ( baseDownloadPromise . promise ) ;
10041017 }
@@ -1044,23 +1057,22 @@ export class Viewer {
10441057 * @param {boolean } progressiveBuild Construct file sections into splat buffers as they are downloaded
10451058 * @param {function } onSectionBuilt Function to be called when new section is added to the file
10461059 * @param {string } format File format of the scene
1060+ * @param {object } headers Optional HTTP headers to pass to use for downloading splat scene
10471061 * @return {AbortablePromise }
10481062 */
10491063 downloadSplatSceneToSplatBuffer ( path , splatAlphaRemovalThreshold = 1 , onProgress = undefined ,
1050- progressiveBuild = false , onSectionBuilt = undefined , format ) {
1064+ progressiveBuild = false , onSectionBuilt = undefined , format , headers ) {
10511065
10521066 const optimizeSplatData = progressiveBuild ? false : this . optimizeSplatData ;
10531067 try {
10541068 if ( format === SceneFormat . Splat ) {
1055- return SplatLoader . loadFromURL ( path , onProgress , progressiveBuild ,
1056- onSectionBuilt , splatAlphaRemovalThreshold ,
1057- this . inMemoryCompressionLevel , optimizeSplatData ) ;
1069+ return SplatLoader . loadFromURL ( path , onProgress , progressiveBuild , onSectionBuilt , splatAlphaRemovalThreshold ,
1070+ this . inMemoryCompressionLevel , optimizeSplatData , headers ) ;
10581071 } else if ( format === SceneFormat . KSplat ) {
1059- return KSplatLoader . loadFromURL ( path , onProgress , progressiveBuild , onSectionBuilt ) ;
1072+ return KSplatLoader . loadFromURL ( path , onProgress , progressiveBuild , onSectionBuilt , headers ) ;
10601073 } else if ( format === SceneFormat . Ply ) {
1061- return PlyLoader . loadFromURL ( path , onProgress , progressiveBuild , onSectionBuilt ,
1062- splatAlphaRemovalThreshold , this . inMemoryCompressionLevel ,
1063- optimizeSplatData , this . sphericalHarmonicsDegree ) ;
1074+ return PlyLoader . loadFromURL ( path , onProgress , progressiveBuild , onSectionBuilt , splatAlphaRemovalThreshold ,
1075+ this . inMemoryCompressionLevel , optimizeSplatData , this . sphericalHarmonicsDegree , headers ) ;
10641076 }
10651077 } catch ( e ) {
10661078 if ( e instanceof DirectLoadError ) {
@@ -1870,7 +1882,7 @@ export class Viewer {
18701882 mvpMatrix . copy ( this . camera . matrixWorld ) . invert ( ) ;
18711883 const mvpCamera = this . perspectiveCamera || this . camera ;
18721884 mvpMatrix . premultiply ( mvpCamera . projectionMatrix ) ;
1873- mvpMatrix . multiply ( this . splatMesh . matrixWorld ) ;
1885+ if ( ! this . splatMesh . dynamicMode ) mvpMatrix . multiply ( this . splatMesh . matrixWorld ) ;
18741886
18751887 let gpuAcceleratedSortPromise = Promise . resolve ( true ) ;
18761888 if ( this . gpuAcceleratedSort && ( queuedSorts . length <= 1 || queuedSorts . length % 2 === 0 ) ) {
@@ -1979,7 +1991,7 @@ export class Viewer {
19791991
19801992 if ( splatTree ) {
19811993 baseModelView . copy ( this . camera . matrixWorld ) . invert ( ) ;
1982- baseModelView . multiply ( this . splatMesh . matrixWorld ) ;
1994+ if ( ! this . splatMesh . dynamicMode ) baseModelView . multiply ( this . splatMesh . matrixWorld ) ;
19831995
19841996 let nodeRenderCount = 0 ;
19851997 let splatRenderCount = 0 ;
0 commit comments