@@ -69,14 +69,57 @@ export class PanoramaRenderer {
69
69
}
70
70
71
71
addClassicPanorama ( ) {
72
- const classicPanorama = new ClassicPanoramaRenderer ( panoramaFiles . map ( file => join ( 'background' , file ) ) )
73
- classicPanorama . panoramaGroup . onBeforeRender = ( ) => {
72
+ const panorGeo = new THREE . BoxGeometry ( 1000 , 1000 , 1000 )
73
+ const loader = new THREE . TextureLoader ( )
74
+ const panorMaterials = [ ] as THREE . MeshBasicMaterial [ ]
75
+
76
+ for ( const file of panoramaFiles ) {
77
+ const texture = loader . load ( join ( 'background' , file ) )
78
+
79
+ // Instead of using repeat/offset to flip, we'll use the texture matrix
80
+ texture . matrixAutoUpdate = false
81
+ texture . matrix . set (
82
+ - 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 1
83
+ )
84
+
85
+ texture . wrapS = THREE . ClampToEdgeWrapping // Changed from RepeatWrapping
86
+ texture . wrapT = THREE . ClampToEdgeWrapping // Changed from RepeatWrapping
87
+ texture . minFilter = THREE . LinearFilter
88
+ texture . magFilter = THREE . LinearFilter
89
+
90
+ panorMaterials . push ( new THREE . MeshBasicMaterial ( {
91
+ map : texture ,
92
+ transparent : true ,
93
+ side : THREE . DoubleSide ,
94
+ depthWrite : false ,
95
+ } ) )
96
+ }
97
+
98
+ const panoramaBox = new THREE . Mesh ( panorGeo , panorMaterials )
99
+ panoramaBox . onBeforeRender = ( ) => {
74
100
this . time += 0.01
75
- classicPanorama . panoramaGroup . rotation . y = Math . PI + this . time * 0.01
76
- classicPanorama . panoramaGroup . rotation . z = Math . sin ( - this . time * 0.001 ) * 0.001
101
+ panoramaBox . rotation . y = Math . PI + this . time * 0.01
102
+ panoramaBox . rotation . z = Math . sin ( - this . time * 0.001 ) * 0.001
103
+ }
104
+
105
+ const group = new THREE . Object3D ( )
106
+ group . add ( panoramaBox )
107
+
108
+ // Add squids
109
+ for ( let i = 0 ; i < 20 ; i ++ ) {
110
+ const m = new EntityMesh ( '1.16.4' , 'squid' ) . mesh
111
+ m . position . set ( Math . random ( ) * 30 - 15 , Math . random ( ) * 20 - 10 , Math . random ( ) * 10 - 17 )
112
+ m . rotation . set ( 0 , Math . PI + Math . random ( ) , - Math . PI / 4 , 'ZYX' )
113
+ const v = Math . random ( ) * 0.01
114
+ m . children [ 0 ] . onBeforeRender = ( ) => {
115
+ m . rotation . y += v
116
+ m . rotation . z = Math . cos ( panoramaBox . rotation . y * 3 ) * Math . PI / 4 - Math . PI / 2
117
+ }
118
+ group . add ( m )
77
119
}
78
- this . scene . add ( classicPanorama . panoramaGroup )
79
- this . panoramaGroup = classicPanorama . panoramaGroup
120
+
121
+ this . scene . add ( group )
122
+ this . panoramaGroup = group
80
123
}
81
124
82
125
async worldBlocksPanorama ( ) {
@@ -167,54 +210,58 @@ export class PanoramaRenderer {
167
210
}
168
211
}
169
212
170
- class ClassicPanoramaRenderer {
171
- panoramaGroup : THREE . Object3D
213
+ // export class ClassicPanoramaRenderer {
214
+ // panoramaGroup: THREE.Object3D
172
215
173
- constructor ( private readonly backgroundFiles : string [ ] ) {
174
- const panorGeo = new THREE . BoxGeometry ( 1000 , 1000 , 1000 )
175
- const loader = new THREE . TextureLoader ( )
176
- const panorMaterials = [ ] as THREE . MeshBasicMaterial [ ]
216
+ // constructor (private readonly backgroundFiles: string[], onRender: Array<(sizeChanged: boolean) => void>, addSquids = true ) {
217
+ // const panorGeo = new THREE.BoxGeometry(1000, 1000, 1000)
218
+ // const loader = new THREE.TextureLoader()
219
+ // const panorMaterials = [] as THREE.MeshBasicMaterial[]
177
220
178
- for ( const file of this . backgroundFiles ) {
179
- const texture = loader . load ( file )
221
+ // for (const file of this.backgroundFiles) {
222
+ // const texture = loader.load(file)
180
223
181
- // Instead of using repeat/offset to flip, we'll use the texture matrix
182
- texture . matrixAutoUpdate = false
183
- texture . matrix . set (
184
- - 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 1
185
- )
224
+ // // Instead of using repeat/offset to flip, we'll use the texture matrix
225
+ // texture.matrixAutoUpdate = false
226
+ // texture.matrix.set(
227
+ // -1, 0, 1, 0, 1, 0, 0, 0, 1
228
+ // )
186
229
187
- texture . wrapS = THREE . ClampToEdgeWrapping // Changed from RepeatWrapping
188
- texture . wrapT = THREE . ClampToEdgeWrapping // Changed from RepeatWrapping
189
- texture . minFilter = THREE . LinearFilter
190
- texture . magFilter = THREE . LinearFilter
230
+ // texture.wrapS = THREE.ClampToEdgeWrapping // Changed from RepeatWrapping
231
+ // texture.wrapT = THREE.ClampToEdgeWrapping // Changed from RepeatWrapping
232
+ // texture.minFilter = THREE.LinearFilter
233
+ // texture.magFilter = THREE.LinearFilter
191
234
192
- panorMaterials . push ( new THREE . MeshBasicMaterial ( {
193
- map : texture ,
194
- transparent : true ,
195
- side : THREE . DoubleSide ,
196
- depthWrite : false ,
197
- } ) )
198
- }
235
+ // panorMaterials.push(new THREE.MeshBasicMaterial({
236
+ // map: texture,
237
+ // transparent: true,
238
+ // side: THREE.DoubleSide,
239
+ // depthWrite: false,
240
+ // }))
241
+ // }
199
242
200
- const panoramaBox = new THREE . Mesh ( panorGeo , panorMaterials )
243
+ // const panoramaBox = new THREE.Mesh(panorGeo, panorMaterials)
244
+ // panoramaBox.onBeforeRender = () => {
245
+ // }
201
246
202
- const group = new THREE . Object3D ( )
203
- group . add ( panoramaBox )
247
+ // const group = new THREE.Object3D()
248
+ // group.add(panoramaBox)
204
249
205
- // Add squids
206
- for ( let i = 0 ; i < 20 ; i ++ ) {
207
- const m = new EntityMesh ( '1.16.4' , 'squid' ) . mesh
208
- m . position . set ( Math . random ( ) * 30 - 15 , Math . random ( ) * 20 - 10 , Math . random ( ) * 10 - 17 )
209
- m . rotation . set ( 0 , Math . PI + Math . random ( ) , - Math . PI / 4 , 'ZYX' )
210
- const v = Math . random ( ) * 0.01
211
- m . children [ 0 ] . onBeforeRender = ( ) => {
212
- m . rotation . y += v
213
- m . rotation . z = Math . cos ( panoramaBox . rotation . y * 3 ) * Math . PI / 4 - Math . PI / 2
214
- }
215
- group . add ( m )
216
- }
250
+ // if (addSquids) {
251
+ // // Add squids
252
+ // for (let i = 0; i < 20; i++) {
253
+ // const m = new EntityMesh('1.16.4', 'squid').mesh
254
+ // m.position.set(Math.random() * 30 - 15, Math.random() * 20 - 10, Math.random() * 10 - 17)
255
+ // m.rotation.set(0, Math.PI + Math.random(), -Math.PI / 4, 'ZYX')
256
+ // const v = Math.random() * 0.01
257
+ // onRender.push(() => {
258
+ // m.rotation.y += v
259
+ // m.rotation.z = Math.cos(panoramaBox.rotation.y * 3) * Math.PI / 4 - Math.PI / 2
260
+ // })
261
+ // group.add(m)
262
+ // }
263
+ // }
217
264
218
- this . panoramaGroup = group
219
- }
220
- }
265
+ // this.panoramaGroup = group
266
+ // }
267
+ // }
0 commit comments