@@ -9,8 +9,9 @@ import { updateLayeredMaterialNodeImagery } from '../../Process/LayeredMaterialN
99import { panoramaCulling , panoramaSubdivisionControl } from '../../Process/PanoramaTileProcessing' ;
1010import PanoramaTileBuilder from './Panorama/PanoramaTileBuilder' ;
1111import SubdivisionControl from '../../Process/SubdivisionControl' ;
12+ import ProjectionType from './Panorama/Constants' ;
1213
13- export function createPanoramaLayer ( id , coordinates , ratio , options = { } ) {
14+ export function createPanoramaLayer ( id , coordinates , type , options = { } ) {
1415 const tileLayer = new GeometryLayer ( id , options . object3d || new THREE . Group ( ) ) ;
1516
1617 coordinates . xyz ( tileLayer . object3d . position ) ;
@@ -26,7 +27,7 @@ export function createPanoramaLayer(id, coordinates, ratio, options = {}) {
2627 south : - 90 ,
2728 } ) ;
2829
29- if ( ratio == 2 ) {
30+ if ( type === ProjectionType . SPHERICAL ) {
3031 // equirectangular -> spherical geometry
3132 tileLayer . schemeTile = [
3233 new Extent ( 'EPSG:4326' , {
@@ -40,7 +41,7 @@ export function createPanoramaLayer(id, coordinates, ratio, options = {}) {
4041 north : 90 ,
4142 south : - 90 ,
4243 } ) ] ;
43- } else {
44+ } else if ( type === ProjectionType . CYLINDRICAL ) {
4445 // cylindrical geometry
4546 tileLayer . schemeTile = [
4647 new Extent ( 'EPSG:4326' , {
@@ -64,6 +65,9 @@ export function createPanoramaLayer(id, coordinates, ratio, options = {}) {
6465 north : 90 ,
6566 south : - 90 ,
6667 } ) ] ;
68+ } else {
69+ throw new Error ( `Unsupported panorama projection type ${ type } .
70+ Only ProjectionType.SPHERICAL and ProjectionType.CYLINDRICAL are supported` ) ;
6771 }
6872 tileLayer . disableSkirt = true ;
6973
@@ -146,13 +150,13 @@ export function createPanoramaLayer(id, coordinates, ratio, options = {}) {
146150 function subdivision ( context , layer , node ) {
147151 if ( SubdivisionControl . hasEnoughTexturesToSubdivide ( context , layer , node ) ) {
148152 return panoramaSubdivisionControl (
149- options . maxSubdivisionLevel || 10 , new THREE . Vector2 ( 512 , 512 / ratio ) ) ( context , layer , node ) ;
153+ options . maxSubdivisionLevel || 10 , new THREE . Vector2 ( 512 , 256 ) ) ( context , layer , node ) ;
150154 }
151155 return false ;
152156 }
153157
154158 tileLayer . update = processTiledGeometryNode ( panoramaCulling , subdivision ) ;
155- tileLayer . builder = new PanoramaTileBuilder ( ratio ) ;
159+ tileLayer . builder = new PanoramaTileBuilder ( type , options . ratio ) ;
156160 tileLayer . onTileCreated = nodeInitFn ;
157161 tileLayer . type = 'geometry' ;
158162 tileLayer . protocol = 'tile' ;
@@ -167,7 +171,7 @@ export function createPanoramaLayer(id, coordinates, ratio, options = {}) {
167171 return tileLayer ;
168172}
169173
170- function PanoramaView ( viewerDiv , coordinates , ratio , options = { } ) {
174+ function PanoramaView ( viewerDiv , coordinates , type , options = { } ) {
171175 THREE . Object3D . DefaultUp . set ( 0 , 0 , 1 ) ;
172176
173177 // Setup View
@@ -184,10 +188,12 @@ function PanoramaView(viewerDiv, coordinates, ratio, options = {}) {
184188 // look at to the north
185189 camera . lookAt ( new THREE . Vector3 ( 0 , 1 , 0 ) . add ( camera . position ) ) ;
186190
187- camera . updateProjectionMatrix ( ) ;
191+ if ( camera . updateProjectionMatrix ) {
192+ camera . updateProjectionMatrix ( ) ;
193+ }
188194 camera . updateMatrixWorld ( ) ;
189195
190- const tileLayer = createPanoramaLayer ( 'panorama' , coordinates , ratio , options ) ;
196+ const tileLayer = createPanoramaLayer ( 'panorama' , coordinates , type , options ) ;
191197
192198 View . prototype . addLayer . call ( this , tileLayer ) ;
193199
0 commit comments