@operato/scene-visualizer 8.0.0-beta.0 → 8.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/package.json +5 -5
  2. package/CHANGELOG.md +0 -640
  3. package/attachments/0d91a37d-c2d7-4c6d-88dc-a29e5bbea361.png +0 -0
  4. package/attachments/1b07c8d3-07d5-4007-b02e-031ee1755539.glb +0 -0
  5. package/attachments/226c6c23-c4fd-46c8-93e3-3d3d9c4bb8a9.glb +0 -0
  6. package/attachments/4425ca46-cf1d-476d-9185-dcb881ecad1f.glb +0 -0
  7. package/attachments/51e7c45d-6eae-4baf-a4e2-ba979b7e77cd.glb +0 -0
  8. package/attachments/54427925-c109-4499-875c-fb14207b95c5.glb +0 -0
  9. package/attachments/8cc70a65-e20f-4187-83c8-64deb3faf3d9.glb +0 -0
  10. package/attachments/964d004d-1fe7-4224-89a6-2b6e86db233c.glb +0 -0
  11. package/attachments/ff47fd63-6f1c-4a69-b965-9bb03797a415.png +0 -0
  12. package/db.sqlite +0 -0
  13. package/demo/index-modeller.html +0 -112
  14. package/demo/index.html +0 -109
  15. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -25
  16. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -25
  17. package/logs/application-2025-01-07-10.log +0 -106
  18. package/logs/application-2025-01-07-14.log +0 -4
  19. package/logs/application-2025-01-07-15.log +0 -4
  20. package/logs/connections-2025-01-07-10.log +0 -106
  21. package/logs/connections-2025-01-07-14.log +0 -53
  22. package/logs/connections-2025-01-07-15.log +0 -53
  23. package/schema.graphql +0 -4552
  24. package/src/banner.ts +0 -88
  25. package/src/camera.ts +0 -132
  26. package/src/component.d.ts +0 -10
  27. package/src/cube.ts +0 -39
  28. package/src/cylinder.ts +0 -39
  29. package/src/desk.ts +0 -135
  30. package/src/editors/index.ts +0 -13
  31. package/src/editors/property-editor-gltf-info.ts +0 -135
  32. package/src/editors/property-editor-location-increase-pattern.ts +0 -260
  33. package/src/effects/outline.ts +0 -54
  34. package/src/ellipse.ts +0 -37
  35. package/src/gltf-object.ts +0 -117
  36. package/src/html-overlay-element.ts +0 -13
  37. package/src/index.ts +0 -29
  38. package/src/light.ts +0 -155
  39. package/src/polygon.ts +0 -88
  40. package/src/rack-table-cell.ts +0 -386
  41. package/src/rack-table.ts +0 -1296
  42. package/src/rack.ts +0 -232
  43. package/src/rect.ts +0 -39
  44. package/src/scene/component.ts +0 -38
  45. package/src/sphere.ts +0 -39
  46. package/src/sprite.ts +0 -30
  47. package/src/stock.ts +0 -262
  48. package/src/templates/3d-container.ts +0 -21
  49. package/src/templates/banner.ts +0 -21
  50. package/src/templates/camera.ts +0 -25
  51. package/src/templates/cube.ts +0 -20
  52. package/src/templates/cylinder.ts +0 -20
  53. package/src/templates/desk.ts +0 -20
  54. package/src/templates/gltf-object.ts +0 -20
  55. package/src/templates/index.ts +0 -29
  56. package/src/templates/light.ts +0 -23
  57. package/src/templates/pallet.ts +0 -20
  58. package/src/templates/rack-table.ts +0 -21
  59. package/src/templates/sphere.ts +0 -20
  60. package/src/templates/sprite.ts +0 -21
  61. package/src/templates/visualizer.ts +0 -21
  62. package/src/templates/wall.ts +0 -20
  63. package/src/text.ts +0 -10
  64. package/src/three-container-editor.ts +0 -187
  65. package/src/three-container.ts +0 -724
  66. package/src/three-controls.ts +0 -778
  67. package/src/three-layout.ts +0 -25
  68. package/src/three-space.ts +0 -732
  69. package/src/threed/common.ts +0 -21
  70. package/src/threed/floor/floor.ts +0 -62
  71. package/src/threed/html/elements.ts +0 -27
  72. package/src/threed/index.ts +0 -15
  73. package/src/threed/real-object-camera-meshed.ts +0 -67
  74. package/src/threed/real-object-camera.ts +0 -41
  75. package/src/threed/real-object-dom-element.ts +0 -55
  76. package/src/threed/real-object-dummy.ts +0 -13
  77. package/src/threed/real-object-extrude.ts +0 -210
  78. package/src/threed/real-object-gltf.ts +0 -136
  79. package/src/threed/real-object-group.ts +0 -35
  80. package/src/threed/real-object-mesh.ts +0 -74
  81. package/src/threed/real-object-plane.ts +0 -27
  82. package/src/threed/real-object-scene.ts +0 -84
  83. package/src/threed/real-object-sprite-2d.ts +0 -54
  84. package/src/threed/real-object-sprite.ts +0 -64
  85. package/src/threed/real-object-text.ts +0 -86
  86. package/src/threed/real-object.ts +0 -326
  87. package/src/threed/texture/canvas-texture.ts +0 -67
  88. package/src/threed/texture/text-texture.ts +0 -100
  89. package/src/threed/three-dimensional-container.ts +0 -9
  90. package/src/threed/utils/bound-uv-generator.ts +0 -80
  91. package/src/visualizer.ts +0 -319
  92. package/src/wall.ts +0 -50
  93. package/tsconfig.json +0 -24
  94. package/tsconfig.tsbuildinfo +0 -1
  95. package/web-dev-server.config.mjs +0 -27
@@ -1,732 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { Component, ComponentNature, Container, error, FPS, Layout, Properties } from '@hatiolab/things-scene'
6
- import * as THREE from 'three'
7
- import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'
8
- import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'
9
-
10
- import ThreeControls from './three-controls'
11
- import './three-layout'
12
- import { RealObject } from './threed/real-object'
13
- import { ThreeDimensionalContainer } from './threed/three-dimensional-container'
14
- import { CSS3DRenderer } from 'three/examples/jsm/renderers/CSS3DRenderer'
15
- import { createFloor } from './threed/floor/floor'
16
- import { RealObjectDomElement } from './threed'
17
-
18
- const NATURE: ComponentNature = {
19
- mutable: false,
20
- resizable: true,
21
- rotatable: true,
22
- properties: [
23
- {
24
- type: 'select',
25
- label: 'precision',
26
- name: 'precision',
27
- property: {
28
- options: [
29
- {
30
- display: 'High',
31
- value: 'highp'
32
- },
33
- {
34
- display: 'Medium',
35
- value: 'mediump'
36
- },
37
- {
38
- display: 'Low',
39
- value: 'lowp'
40
- }
41
- ]
42
- }
43
- },
44
- {
45
- type: 'checkbox',
46
- label: 'anti-alias',
47
- name: 'antialias',
48
- property: 'antialias'
49
- },
50
- {
51
- type: 'checkbox',
52
- label: 'controller',
53
- name: 'controller',
54
- property: 'controller'
55
- }
56
- ],
57
- help: 'scene/component/three-space'
58
- }
59
-
60
- const WEBGL_NO_SUPPORT_TEXT = 'WebGL no support'
61
-
62
- export class ThreeSpace extends Container implements ThreeDimensionalContainer {
63
- _scene3d?: THREE.Scene
64
- _initalizeComplete?: Promise<void>
65
-
66
- _mixer?: THREE.AnimationMixer
67
-
68
- _camera?: THREE.PerspectiveCamera
69
- _renderer3d?: THREE.WebGLRenderer
70
-
71
- _mouse?: THREE.Vector2
72
-
73
- _clock?: THREE.Clock
74
-
75
- _controls?: any
76
- _onFocus?: (e: FocusEvent) => void
77
- _onResize?: (e: Event) => void
78
- _noSupportWebgl: boolean = false
79
-
80
- _raycaster = new THREE.Raycaster()
81
-
82
- _lastFocused?: RealObject
83
- _lastHovered?: RealObject
84
-
85
- private _css3DScene?: THREE.Scene
86
- private _css3DRenderer?: CSS3DRenderer
87
-
88
- composer?: EffectComposer
89
-
90
- containable(component: Component) {
91
- return component.is3dish()
92
- }
93
-
94
- is3dContainer() {
95
- return true
96
- }
97
-
98
- /* THREE Object related .. */
99
-
100
- createObjects(components: Component[]) {
101
- for (let component of components) {
102
- try {
103
- var item = component.realObject
104
-
105
- if (item) {
106
- if (component.isHTMLElement()) {
107
- this.css3DScene.add((item as RealObjectDomElement).object3d)
108
- } else {
109
- this._scene3d!.add(item.object3d)
110
- }
111
- }
112
- } catch (err) {
113
- error(err)
114
- }
115
- }
116
- }
117
-
118
- destroy_scene3d() {
119
- this.stop()
120
-
121
- window.removeEventListener('focus', this._onFocus!)
122
- window.removeEventListener('resize', this._onResize!)
123
-
124
- if (this._renderer3d) this._renderer3d.clear()
125
-
126
- if (this._controls?.autoRotate) {
127
- this._controls.doAutoRotate(false)
128
- }
129
-
130
- delete this._renderer3d
131
- delete this._camera
132
- delete this._controls
133
-
134
- if (this._scene3d) {
135
- let children = this._scene3d.children.slice()
136
- for (let i in children) {
137
- let child = children[i] as any
138
- if (child.dispose) child.dispose()
139
- if (child.geometry && child.geometry.dispose) child.geometry.dispose()
140
- if (child.material && child.material.dispose) child.material.dispose()
141
- if (child.texture && child.texture.dispose) child.texture.dispose()
142
- this._scene3d.remove(child)
143
- }
144
- }
145
-
146
- delete this._scene3d
147
- }
148
-
149
- update() {
150
- var { width, height } = this.bounds
151
-
152
- var {
153
- fov = 45,
154
- near = 0.1,
155
- far = 20000,
156
- antialias = true,
157
- precision = 'highp',
158
- cameraX,
159
- cameraY,
160
- cameraZ,
161
- exposure = 2.5
162
- } = this.state
163
-
164
- var components = this.components || []
165
-
166
- // SCENE
167
- this._scene3d = new THREE.Scene()
168
-
169
- // CAMERA
170
- var aspect = width / height
171
-
172
- this._camera = new THREE.PerspectiveCamera(fov, aspect, near, far)
173
-
174
- var cameraXPos = height * 0.8,
175
- cameraYPos = width * 0.8,
176
- cameraZPos = Math.min(500, Math.floor(Math.min(width, height)))
177
- // cameraZPos = Math.floor(Math.min(width, height))
178
-
179
- if (cameraX != undefined) cameraXPos = cameraX * width
180
- if (cameraY != undefined) cameraYPos = cameraY * height
181
- if (cameraZ != undefined) cameraZPos = cameraZ * Math.floor(Math.min(width, height))
182
-
183
- this._camera.position.set(cameraXPos, cameraZPos, cameraYPos)
184
-
185
- this._scene3d.add(this._camera)
186
- this._camera.lookAt(this._scene3d.position)
187
- this._camera.zoom = this.getState('zoom') * 0.01
188
-
189
- try {
190
- const canvas = document.createElement('canvas')
191
- let context = canvas!.getContext('webgl2')!
192
-
193
- var renderer3d = new THREE.WebGLRenderer({
194
- canvas,
195
- context,
196
- precision,
197
- alpha: true,
198
- antialias
199
- })
200
- } catch (e) {
201
- this._noSupportWebgl = true
202
- return
203
- }
204
-
205
- this._renderer3d = renderer3d
206
-
207
- renderer3d!.autoClear = true
208
- // @ts-ignore for three@0.150.1
209
- renderer3d!.outputColorSpace = THREE.SRGBColorSpace
210
- renderer3d!.useLegacyLights = false
211
- renderer3d!.toneMappingExposure = Math.pow(exposure, 5.0)
212
- renderer3d!.toneMapping = THREE.LinearToneMapping
213
- renderer3d!.shadowMap.enabled = true
214
- renderer3d!.setClearColor(0xffffff, 0) // transparent
215
- renderer3d!.setSize(width, height)
216
-
217
- // CONTROLS
218
- this._controls = new (ThreeControls as any)(this._camera, this)
219
- this._controls.cameraChanged = true
220
-
221
- // Lights
222
- var _hemiLight = new THREE.HemisphereLight(0xdddddd, 0x333333, 0.035)
223
- var _directionalLight = new THREE.DirectionalLight(0xd6e1ff, 0.01)
224
- var _pointLight1 = new THREE.PointLight(0xd6e1ff, 1, undefined, 2)
225
-
226
- _pointLight1.power = cameraZPos * 50
227
- _pointLight1.castShadow = true
228
- _pointLight1.position.set(0, cameraZPos, 0)
229
- _pointLight1.shadow.camera.near = 0.1
230
- _pointLight1.shadow.camera.far = cameraZPos * 2
231
-
232
- // const helper = new THREE.CameraHelper(_pointLight1.shadow.camera)
233
- // this._scene3d?.add(helper)
234
-
235
- this.scene3d!.add(_hemiLight)
236
- this.scene3d!.add(_pointLight1)
237
- this._camera.add(_directionalLight)
238
-
239
- this._mouse = new THREE.Vector2()
240
-
241
- this._clock = new THREE.Clock(true)
242
- this._mixer = new THREE.AnimationMixer(this.scene3d!)
243
-
244
- this.createObjects(components)
245
-
246
- this._camera.updateProjectionMatrix()
247
-
248
- const floor = createFloor(this)
249
- // if (this._floor) {
250
- // this.object3d.remove(this._floor)
251
- // this._floor.clear()
252
- // delete this._floor
253
- // }
254
-
255
- if (floor) {
256
- // this._floor = floor
257
- this._scene3d.add(floor)
258
- }
259
-
260
- // this.invalidate()
261
-
262
- // postprocessing
263
-
264
- var composer = (this.composer = new EffectComposer(renderer3d!))
265
- composer.setSize(width, height)
266
-
267
- const renderPass = new RenderPass(this._scene3d, this._camera)
268
- composer.addPass(renderPass)
269
-
270
- this._onFocus = (e: FocusEvent) => {
271
- this.render_threed()
272
- }
273
-
274
- this._onResize = (e: Event) => {
275
- this.resize()
276
- }
277
-
278
- window.addEventListener('resize', this._onResize)
279
- window.addEventListener('focus', this._onFocus)
280
-
281
- this.buildOverlays()
282
- this.resize()
283
- }
284
-
285
- resize() {
286
- const { width, height } = this.bounds
287
-
288
- this._camera!.aspect = width / height
289
-
290
- this.renderer3d!.setSize(width, height)
291
- this.css3DRenderer.setSize(width, height)
292
-
293
- this.composer?.setSize(width, height)
294
- this._camera!.updateProjectionMatrix()
295
- }
296
-
297
- init_scene3d() {
298
- this.root.on('redraw', this.onredraw, this)
299
-
300
- if (this._scene3d) {
301
- this.destroy_scene3d()
302
- }
303
-
304
- this.update()
305
-
306
- this.onchangeData && this.onchangeData(this.data, this.data)
307
- }
308
-
309
- threed_animate() {
310
- if (!this._controls) {
311
- return
312
- }
313
-
314
- if (this._mixer) {
315
- this._mixer.update(this._clock!.getDelta())
316
- }
317
-
318
- this._controls.update()
319
-
320
- if (this.state.autoRotate) {
321
- this.invalidate()
322
- }
323
-
324
- this.render_threed()
325
- }
326
-
327
- stop() {}
328
-
329
- get scene3d() {
330
- if (!this._scene3d) {
331
- this.init_scene3d()
332
- }
333
-
334
- return this._scene3d
335
- }
336
-
337
- get renderer3d() {
338
- return this._renderer3d
339
- }
340
-
341
- get mixer() {
342
- return this._mixer
343
- }
344
-
345
- get zoom() {
346
- return this._camera?.zoom
347
- }
348
-
349
- /**
350
- * CSS3DRenderer용 THREE.Scene을 제공
351
- */
352
- get css3DScene() {
353
- if (!this._css3DScene) {
354
- this._css3DScene = this.buildCSS3DScene()
355
- }
356
- return this._css3DScene
357
- }
358
-
359
- protected buildCSS3DScene() {
360
- return new THREE.Scene()
361
- }
362
-
363
- protected disposeCSS3DScene() {
364
- var children = [...this.css3DScene.children]
365
- children.forEach(child => this.css3DScene.remove(child))
366
- }
367
-
368
- /* css3d-renderer */
369
-
370
- /**
371
- * css3d-renderer getter
372
- */
373
- get css3DRenderer() {
374
- if (!this._css3DRenderer) {
375
- this._css3DRenderer = this.createCSS3DRenderer()
376
- }
377
-
378
- return this._css3DRenderer
379
- }
380
-
381
- protected createCSS3DRenderer() {
382
- var renderer = new CSS3DRenderer()
383
- var div = renderer.domElement
384
- div.style.position = 'absolute'
385
- div.style.top = '0'
386
- div.style.pointerEvents = 'none'
387
-
388
- if (this.app.isViewMode) {
389
- // disableAllUserEvents(div)
390
- } else {
391
- div.style.pointerEvents = 'none'
392
- }
393
-
394
- return renderer
395
- }
396
-
397
- protected disposeCSS3DRenderer() {
398
- // Nothing to do
399
- }
400
-
401
- /**
402
- * element내부에 필요한 overlay들을 생성
403
- * ViewRenderer에서는 CSS3DRenderer와 GLRendering을 위한 canvas를 오버레이로 만든다.
404
- * Warn: this.element는 아직 만들어지지 않은 상태에 buildOverlays가 호출됨.
405
- * @param into
406
- */
407
- buildOverlays() {
408
- this.element.appendChild(this.css3DRenderer.domElement)
409
- }
410
-
411
- render_threed() {
412
- if (this.composer) {
413
- this.composer.render()
414
- }
415
- }
416
-
417
- /* Container Overides .. */
418
- render(ctx: CanvasRenderingContext2D) {
419
- if (this.app.isViewMode) {
420
- this.setState('threed', true)
421
- }
422
-
423
- if (this.state.threed && !this._noSupportWebgl && this._camera) {
424
- this.css3DRenderer.render(this.css3DScene, this._camera!)
425
- return
426
- }
427
-
428
- super.render(ctx)
429
- }
430
-
431
- postrender(ctx: CanvasRenderingContext2D) {
432
- var { left, top, debug, threed } = this.state
433
-
434
- var { width, height } = this.bounds
435
-
436
- // ios에서 width, height에 소수점이 있으면 3d를 표현하지 못하는 문제가 있어 정수화
437
- width = Math.floor(width)
438
- height = Math.floor(height)
439
-
440
- if (threed) {
441
- if (!this._scene3d) {
442
- this.init_scene3d()
443
- this.render_threed()
444
- }
445
-
446
- if (this._noSupportWebgl) {
447
- this._showWebglNoSupportText(ctx)
448
- return
449
- }
450
-
451
- if (!this._renderer3d) {
452
- return
453
- }
454
-
455
- var { width: rendererWidth, height: rendererHeight } = this._renderer3d.getSize(new THREE.Vector2())
456
-
457
- ctx.drawImage(this._renderer3d.domElement, 0, 0, rendererWidth, rendererHeight, left, top, width, height)
458
-
459
- if (debug) {
460
- ctx.font = 100 + 'px Arial'
461
- ctx.textAlign = 'center'
462
- ctx.fillStyle = 'black'
463
- ctx.globalAlpha = 0.5
464
- ctx.fillText(String(FPS()), 100, 100)
465
- }
466
- } else {
467
- super.postrender(ctx)
468
- }
469
- }
470
-
471
- dispose() {
472
- this.root.off('redraw', this.onredraw, this)
473
-
474
- this.disposeCSS3DScene()
475
-
476
- this.composer?.dispose()
477
- this.destroy_scene3d()
478
-
479
- super.dispose()
480
- }
481
-
482
- get layout() {
483
- return Layout.get('three')
484
- }
485
-
486
- get nature(): ComponentNature {
487
- return NATURE
488
- }
489
-
490
- getObjectByRaycast(): THREE.Object3D | undefined {
491
- var intersects = this.getObjectsByRaycast()
492
-
493
- if (intersects && intersects.length > 0) {
494
- var object: THREE.Object3D | null = intersects[0].object
495
- while (object) {
496
- if (object.userData.context) {
497
- return object
498
- }
499
-
500
- object = object.parent
501
- }
502
- }
503
- }
504
-
505
- getObjectsByRaycast() {
506
- var vector = this._mouse
507
- if (!this._camera) {
508
- return
509
- }
510
-
511
- this._raycaster.setFromCamera(vector!, this._camera)
512
-
513
- var intersects = this._raycaster.intersectObjects(this._scene3d!.children, true)
514
-
515
- return intersects
516
- }
517
-
518
- _showWebglNoSupportText(context: CanvasRenderingContext2D) {
519
- context.save()
520
-
521
- var { width, height } = this.state
522
-
523
- context.font = width / 20 + 'px Arial'
524
- context.textAlign = 'center'
525
- context.fillText(WEBGL_NO_SUPPORT_TEXT, width / 2 - width / 40, height / 2)
526
-
527
- context.restore()
528
- }
529
-
530
- /* Event Handlers */
531
-
532
- onchange(after: Properties, before: Properties) {
533
- if (after.hasOwnProperty('width') || after.hasOwnProperty('height') || after.hasOwnProperty('threed'))
534
- this.destroy_scene3d()
535
-
536
- if (after.hasOwnProperty('autoRotate')) {
537
- if (this._controls) {
538
- this._controls.doAutoRotate(after.autoRotate)
539
- }
540
- }
541
-
542
- if (
543
- after.hasOwnProperty('fov') ||
544
- after.hasOwnProperty('near') ||
545
- after.hasOwnProperty('far') ||
546
- after.hasOwnProperty('zoom')
547
- ) {
548
- if (this._camera) {
549
- const { near, far, zoom, fov } = this.state
550
-
551
- this._camera.near = near
552
- this._camera.far = far
553
- this._camera.zoom = zoom * 0.01
554
- this._camera.fov = fov
555
- this._camera.updateProjectionMatrix()
556
-
557
- this._controls.cameraChanged = true
558
- }
559
- }
560
- }
561
-
562
- onmousedown(e: MouseEvent) {
563
- if (this._controls) {
564
- this._controls.onMouseDown(e)
565
- }
566
- }
567
-
568
- onmouseup(e: MouseEvent) {
569
- if (this._controls) {
570
- if (this._lastFocused) {
571
- ;(this._lastFocused as any)._focused = false
572
- }
573
-
574
- const { left, top, width, height } = this.state
575
-
576
- var pointer = this.transcoordC2S(e.offsetX, e.offsetY)
577
-
578
- this._mouse!.x = ((pointer.x - left) / width) * 2 - 1
579
- this._mouse!.y = -((pointer.y - top) / height) * 2 + 1
580
-
581
- var object = this.getObjectByRaycast()
582
- var realObject = object?.userData.context as RealObject
583
-
584
- if (realObject) {
585
- ;(realObject as any)._focused = true
586
- ;(realObject as any)._focusedAt = performance.now()
587
- this._lastFocused = realObject
588
- realObject.component?.trigger('click', e)
589
- }
590
-
591
- e.stopPropagation()
592
- }
593
- }
594
-
595
- onmousemove(e: MouseEvent) {
596
- if (this._controls) {
597
- const { left, top, width, height } = this.state
598
-
599
- var pointer = this.transcoordC2S(e.offsetX, e.offsetY)
600
-
601
- this._mouse!.x = ((pointer.x - left) / width) * 2 - 1
602
- this._mouse!.y = -((pointer.y - top) / height) * 2 + 1
603
-
604
- var object = this.getObjectByRaycast()
605
- var realObject = object?.userData.context as RealObject
606
-
607
- if (realObject !== this._lastHovered) {
608
- if (this._lastHovered) {
609
- this._lastHovered.component?.trigger('mouseleave', e)
610
- delete this._lastHovered
611
- }
612
-
613
- if (realObject) {
614
- this._lastHovered = realObject
615
- this._lastHovered.component?.trigger('mouseenter', e)
616
- }
617
- }
618
-
619
- this._controls.onMouseMove(e)
620
-
621
- e.stopPropagation()
622
- }
623
- }
624
-
625
- onmouseleave(e: MouseEvent) {}
626
-
627
- onwheel(e: WheelEvent) {
628
- if (this._controls) {
629
- this.handleMouseWheel(e)
630
- e.stopPropagation()
631
- }
632
- }
633
-
634
- ondblclick(e: MouseEvent) {
635
- if (this._controls) {
636
- this.setState('zoom', this.getState('zoom'))
637
- this._controls.reset()
638
- e.stopPropagation()
639
- }
640
- }
641
-
642
- ondragstart(e: DragEvent) {
643
- if (this._controls) {
644
- var pointer = this.transcoordC2S(e.offsetX, e.offsetY)
645
- var { left, top, width, height } = this.bounds
646
-
647
- this._mouse!.x = ((pointer.x - left) / width) * 2 - 1
648
- this._mouse!.y = -((pointer.y - top) / height) * 2 + 1
649
-
650
- this._controls.onDragStart(e)
651
- e.stopPropagation()
652
- }
653
- }
654
-
655
- ondragmove(e: DragEvent) {
656
- if (this._controls) {
657
- this._controls.cameraChanged = true
658
- this._controls.onDragMove(e)
659
- e.stopPropagation()
660
- }
661
- }
662
-
663
- ondragend(e: DragEvent) {
664
- if (this._controls) {
665
- this._controls.cameraChanged = true
666
- this._controls.onDragEnd(e)
667
- e.stopPropagation()
668
- }
669
- }
670
-
671
- ontouchstart(e: TouchEvent) {
672
- if (this._controls) {
673
- this._controls.onTouchStart(e)
674
- e.stopPropagation()
675
- }
676
- }
677
-
678
- onpan(e: TouchEvent) {
679
- if (this._controls) {
680
- this._controls.cameraChanged = true
681
- this._controls.onTouchMove(e)
682
- e.stopPropagation()
683
- }
684
- }
685
- ontouchend(e: TouchEvent) {
686
- if (this._controls) {
687
- this._controls.onTouchEnd(e)
688
- e.stopPropagation()
689
- }
690
- }
691
-
692
- onkeydown(e: KeyboardEvent) {
693
- if (this._controls) {
694
- this._controls.onKeyDown(e)
695
- e.stopPropagation()
696
- }
697
- }
698
-
699
- onpinch(e: TouchEvent) {
700
- if (this._controls) {
701
- var zoom = this.getState('zoom')
702
- //@ts-ignore
703
- zoom *= e.scale
704
-
705
- if (zoom < 100) zoom = 100
706
-
707
- this.setState('zoom', zoom)
708
- e.stopPropagation()
709
- }
710
- }
711
-
712
- ondoubletap() {
713
- this._controls.reset()
714
- }
715
-
716
- handleMouseWheel(event: WheelEvent) {
717
- var delta = 0
718
- var zoom = this.getState('zoom')
719
-
720
- delta = -event.deltaY
721
- zoom += delta * 0.1
722
- if (zoom < 100) zoom = 100
723
-
724
- this.setState('zoom', zoom)
725
- }
726
-
727
- onredraw() {
728
- this.threed_animate()
729
- }
730
- }
731
-
732
- Component.register('3d-space', ThreeSpace)