@operato/scene-visualizer 7.3.18 → 7.3.19

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 +2 -2
  2. package/CHANGELOG.md +0 -631
  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,21 +0,0 @@
1
- import tinycolor from 'tinycolor2'
2
-
3
- export const SCALE_MIN = 0.001
4
-
5
- export function applyAlpha(material: any, alpha: number, fillStyle: any) {
6
- var opacity = 1
7
- if (!fillStyle || fillStyle == 'none' || fillStyle == 'transparent') {
8
- opacity = 0
9
- } else {
10
- var fillAlpha = typeof fillStyle == 'string' ? tinycolor(fillStyle).getAlpha() : 1
11
- opacity = alpha * fillAlpha
12
- }
13
-
14
- material.opacity = opacity
15
- material.transparent = opacity < 1
16
- }
17
-
18
- export const UNIT_DIMENSION = { width: 1, height: 1, depth: 1 }
19
- export const UNIT_SCALE = { x: 1, y: 1, z: 1 }
20
- export const UNIT_TRANSLATE = { x: 0, y: 0, z: 0 }
21
- export const UNIT_ROTATE = { x: 0, y: 0, z: 0 }
@@ -1,62 +0,0 @@
1
- import * as THREE from 'three'
2
- import { Component } from '@hatiolab/things-scene'
3
- import { RealObject } from '../real-object'
4
-
5
- export function createFloor(component: Component): THREE.Mesh | undefined {
6
- var { fillStyle } = component.state
7
-
8
- if (!fillStyle || fillStyle == 'none') {
9
- return
10
- }
11
-
12
- var floorGeometry = new THREE.BoxGeometry(1, 1, 1)
13
- var floorMaterial: THREE.Material | THREE.Material[] | undefined
14
-
15
- const texture = RealObject.buildFillStyleTexture(component)
16
-
17
- if (texture) {
18
- const color = '#424b57'
19
-
20
- floorMaterial = [
21
- new THREE.MeshStandardMaterial({
22
- color
23
- }),
24
- new THREE.MeshStandardMaterial({
25
- color
26
- }),
27
- new THREE.MeshStandardMaterial({
28
- color
29
- }),
30
- new THREE.MeshStandardMaterial({
31
- color
32
- }),
33
- new THREE.MeshStandardMaterial({
34
- map: texture
35
- }),
36
- new THREE.MeshStandardMaterial({
37
- color
38
- })
39
- ]
40
- } else if (typeof fillStyle == 'string') {
41
- floorMaterial = new THREE.MeshStandardMaterial({
42
- color: fillStyle
43
- })
44
- }
45
-
46
- if (!floorMaterial) {
47
- return
48
- }
49
-
50
- const mesh = new THREE.Mesh(floorGeometry, floorMaterial)
51
-
52
- var { width, height } = component.state
53
-
54
- mesh.scale.set(width, height, 5)
55
- mesh.rotation.x = -Math.PI / 2
56
- mesh.position.y = -2
57
-
58
- mesh.name = 'floor'
59
- mesh.receiveShadow = true
60
-
61
- return mesh
62
- }
@@ -1,27 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- export var PIXEL_RATIO = (function () {
6
- var ctx: any = document.createElement('canvas').getContext('2d'),
7
- dpr = window.devicePixelRatio || 1,
8
- bsr =
9
- ctx.webkitBackingStorePixelRatio ||
10
- ctx.mozBackingStorePixelRatio ||
11
- ctx.msBackingStorePixelRatio ||
12
- ctx.oBackingStorePixelRatio ||
13
- ctx.backingStorePixelRatio ||
14
- 1
15
- return dpr / bsr
16
- })()
17
-
18
- export function createCanvas(width: number, height: number): HTMLCanvasElement {
19
- let canvas = document.createElement('canvas')
20
-
21
- canvas.width = width
22
- canvas.height = height
23
- canvas.style.width = width + 'px'
24
- canvas.style.height = height + 'px'
25
-
26
- return canvas
27
- }
@@ -1,15 +0,0 @@
1
- export * from './common'
2
- export * from './three-dimensional-container'
3
- export * from './real-object'
4
- export * from './real-object-dummy'
5
- export * from './real-object-extrude'
6
- export * from './real-object-camera'
7
- export * from './real-object-dom-element'
8
- export * from './real-object-gltf'
9
- export * from './real-object-group'
10
- export * from './real-object-mesh'
11
- export * from './real-object-plane'
12
- export * from './real-object-scene'
13
- export * from './real-object-sprite-2d'
14
- export * from './real-object-sprite'
15
- export * from './real-object-text'
@@ -1,67 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import * as THREE from 'three'
6
-
7
- import { RealObjectMesh } from './real-object-mesh'
8
- import { UNIT_DIMENSION } from './common'
9
-
10
- const DEFAULT = {
11
- far: 100000,
12
- fov: 80,
13
- near: 1,
14
- zoom: 1
15
- }
16
-
17
- export class RealObjectCamera extends RealObjectMesh {
18
- protected _camera?: THREE.PerspectiveCamera
19
-
20
- update() {
21
- super.update()
22
-
23
- this.updateCamera()
24
- }
25
-
26
- get camera(): THREE.PerspectiveCamera {
27
- if (!this._camera) {
28
- this._camera = this.createCamera()
29
- this.updateCamera()
30
- }
31
-
32
- return this._camera
33
- }
34
-
35
- createCamera() {
36
- return new THREE.PerspectiveCamera()
37
- }
38
-
39
- updateCamera() {
40
- var { near = DEFAULT.near, far = DEFAULT.far, fov = DEFAULT.fov, zoom = DEFAULT.zoom } = this.component.state
41
-
42
- this.camera.far = far
43
- this.camera.fov = fov
44
- this.camera.near = near
45
- this.camera.zoom = zoom
46
- }
47
-
48
- build() {
49
- super.build()
50
-
51
- this.object3d.add(this.camera)
52
- }
53
-
54
- clear() {
55
- delete this._camera
56
-
57
- return super.clear()
58
- }
59
-
60
- buildGeometry() {
61
- var { width = 1, height = 1, depth = 1 } = this.component.state.dimension || UNIT_DIMENSION
62
-
63
- var radius = Math.min(width, height, depth) / 2
64
-
65
- this.object3d.geometry = new THREE.SphereGeometry(radius, 32, 32)
66
- }
67
- }
@@ -1,41 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import * as THREE from 'three'
6
-
7
- import { RealObject } from './real-object'
8
-
9
- const DEFAULT = {
10
- far: 100000,
11
- fov: 80,
12
- near: 1,
13
- zoom: 1
14
- }
15
-
16
- export class RealObjectCamera extends RealObject<THREE.PerspectiveCamera> {
17
- protected _camera?: THREE.PerspectiveCamera
18
-
19
- build() {
20
- super.build()
21
- }
22
-
23
- update() {
24
- super.update()
25
-
26
- this.updateCamera()
27
- }
28
-
29
- protected getObject3dInstance() {
30
- return new THREE.PerspectiveCamera()
31
- }
32
-
33
- updateCamera() {
34
- var { near = DEFAULT.near, far = DEFAULT.far, fov = DEFAULT.fov, zoom = DEFAULT.zoom } = this.component.state
35
-
36
- this.object3d.far = far
37
- this.object3d.fov = fov
38
- this.object3d.near = near
39
- this.object3d.zoom = zoom
40
- }
41
- }
@@ -1,55 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { HTMLOverlayElement, HTMLOverlayContainer, DELTA } from '@hatiolab/things-scene'
6
-
7
- import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer.js'
8
- import { RealObject } from './real-object'
9
-
10
- export class RealObjectDomElement extends RealObject<CSS3DObject> {
11
- protected getObject3dInstance() {
12
- return new CSS3DObject((this.component as HTMLOverlayElement | HTMLOverlayContainer).element)
13
- }
14
-
15
- get cz() {
16
- var { zPos = 0 } = this.component.state
17
- var { height } = this.component.bounds
18
- var { tz = 0 } = this.component.delta() as DELTA
19
-
20
- return zPos + tz + height / 2
21
- }
22
-
23
- build() {
24
- super.build()
25
-
26
- var element = (this.component as HTMLOverlayElement | HTMLOverlayContainer).element
27
-
28
- var { width, height } = this.component.bounds
29
-
30
- element.style.width = width + 'px'
31
- element.style.height = height + 'px'
32
-
33
- element.style.left = ''
34
- element.style.top = ''
35
- }
36
-
37
- updateDimension() {
38
- super.updateDimension()
39
-
40
- var dimension = this.dimension
41
- ;(this.component as HTMLOverlayElement | HTMLOverlayContainer).element.style.width = dimension.width + 'px'
42
- ;(this.component as HTMLOverlayElement | HTMLOverlayContainer).element.style.height = dimension.height + 'px'
43
- }
44
-
45
- updateAlpha() {
46
- super.updateAlpha()
47
-
48
- // material의 opacity는 항상 0으로 유지되어야 하며,
49
- // dom element의 opacity에 alpha를 적용해야한다.
50
- // 하지만, 컬러톤의 반영 외에 transparent 기능은 하지 못하므로, 뒤에 있는 오브젝트를 보여주지 못한다.
51
- var { alpha = 1 } = this.component.state
52
-
53
- ;(this.component as HTMLOverlayElement | HTMLOverlayContainer).element.style.opacity = alpha
54
- }
55
- }
@@ -1,13 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import * as THREE from 'three'
6
- import { RealObject } from './real-object'
7
-
8
- export class RealObjectDummy extends RealObject<THREE.Object3D> {
9
- build() {
10
- super.build()
11
- }
12
- update() {}
13
- }
@@ -1,210 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import * as THREE from 'three'
6
-
7
- import { RealObject } from './real-object'
8
-
9
- import { BoundUVGenerator } from './utils/bound-uv-generator'
10
- import { createCanvas } from './html/elements'
11
- import { applyAlpha } from './common'
12
-
13
- export class RealObjectExtrude extends RealObject {
14
- _boundUVGenerator?: BoundUVGenerator
15
- private _mainMesh?: THREE.Mesh
16
- private _sideMesh?: THREE.Mesh
17
-
18
- get shape(): any {
19
- return null
20
- }
21
-
22
- get sideShape() {
23
- return null
24
- }
25
-
26
- get boundUVGenerator() {
27
- if (!this._boundUVGenerator) this._boundUVGenerator = new BoundUVGenerator()
28
-
29
- return this._boundUVGenerator
30
- }
31
-
32
- build() {
33
- super.build()
34
-
35
- var { depth = 1 } = this.component.state
36
-
37
- // 다각형 그리기
38
- var shape = this.shape
39
- if (!shape) {
40
- return
41
- }
42
-
43
- var boundUVGenerator = this.boundUVGenerator
44
-
45
- if (boundUVGenerator) {
46
- boundUVGenerator.setShape({
47
- extrudedShape: shape,
48
- extrudedOptions: {
49
- depth
50
- }
51
- })
52
- }
53
-
54
- var geometry = this.createGeometry(shape)
55
-
56
- var material = this.createMainMaterial()
57
- this._mainMesh = this.createMainMesh(geometry, material as THREE.Material)
58
- this._mainMesh.castShadow = true
59
-
60
- this.object3d.add(this._mainMesh)
61
-
62
- this._sideMesh = this.createSideMesh(geometry, shape /* FIXME , extrudeSettings */)
63
- this._sideMesh.castShadow = true
64
-
65
- this.object3d.add(this._sideMesh)
66
-
67
- this.updateFillStyle()
68
- this.updateStrokeStyle()
69
- }
70
-
71
- createGeometry(shape: THREE.Shape): THREE.BufferGeometry {
72
- const { depth = 1 } = this.component.state
73
-
74
- const extrudeSettings = {
75
- steps: 1,
76
- depth,
77
- bevelEnabled: false,
78
- UVGenerator: this.boundUVGenerator
79
- } as THREE.ExtrudeGeometryOptions
80
-
81
- var geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings)
82
- geometry.center()
83
-
84
- return geometry as any
85
- }
86
-
87
- createMainMaterial() {
88
- return new THREE.MeshStandardMaterial({
89
- metalness: 0.5,
90
- roughness: 0.5
91
- })
92
- }
93
-
94
- createMainMesh(geometry: THREE.BufferGeometry, material: THREE.Material) {
95
- var mesh = new THREE.Mesh(geometry, material)
96
- mesh.rotation.x = -Math.PI / 2
97
- mesh.rotation.y = -Math.PI
98
- mesh.rotation.z = -Math.PI
99
-
100
- return mesh
101
- }
102
-
103
- createSideMesh(geometry: THREE.BufferGeometry, shape: THREE.Shape) {
104
- var { depth = 1, lineWidth = 0 } = this.component.state
105
-
106
- var hole = new THREE.Path()
107
- hole.setFromPoints(shape.getPoints())
108
-
109
- var sideMaterial = new THREE.MeshStandardMaterial({
110
- metalness: 0.5,
111
- roughness: 0.5,
112
- // prevent overlapped layers flickering
113
- polygonOffset: true,
114
- polygonOffsetFactor: -0.1
115
- })
116
-
117
- shape = this.sideShape || shape
118
- shape.holes.push(hole)
119
-
120
- var sideExtrudeSettings = {
121
- steps: 1,
122
- depth: depth + 1,
123
- bevelEnabled: true,
124
- bevelThickness: 0,
125
- bevelSize: lineWidth,
126
- bevelSizeSegments: 5
127
- }
128
-
129
- var sideGeometry = new THREE.ExtrudeGeometry(shape, sideExtrudeSettings)
130
- sideGeometry.center()
131
-
132
- var sideMesh = new THREE.Mesh(sideGeometry, sideMaterial)
133
- sideMesh.rotation.x = -Math.PI / 2
134
- sideMesh.rotation.y = -Math.PI
135
- sideMesh.rotation.z = -Math.PI
136
-
137
- return sideMesh
138
- }
139
-
140
- createTexture() {
141
- function nextPowerOf2(n: number) {
142
- var count = 0
143
-
144
- if (n && !(n & (n - 1))) {
145
- return n
146
- }
147
-
148
- while (n != 0) {
149
- n >>= 1
150
- count += 1
151
- }
152
-
153
- return 1 << count
154
- }
155
-
156
- var { width, height } = this.component.bounds
157
-
158
- var poweredWidth = nextPowerOf2(width)
159
- var poweredHeight = nextPowerOf2(height)
160
-
161
- let canvas = createCanvas(poweredWidth, poweredHeight)
162
- this.component.render(canvas.getContext('2d')!)
163
-
164
- var texture = new THREE.CanvasTexture(canvas)
165
-
166
- texture.needsUpdate = true
167
- texture.wrapS = THREE.RepeatWrapping
168
- texture.wrapT = THREE.RepeatWrapping
169
- texture.offset.set(0, 1 - height / poweredHeight)
170
- texture.repeat.set(width / poweredWidth, height / poweredHeight)
171
- texture.minFilter = THREE.LinearFilter
172
-
173
- return texture
174
- }
175
-
176
- updateAlpha() {
177
- var { alpha = 1, fillStyle, strokeStyle } = this.component.state
178
-
179
- this._mainMesh && applyAlpha(this._mainMesh.material, alpha, fillStyle)
180
- this._sideMesh && applyAlpha(this._sideMesh.material, alpha, strokeStyle)
181
- }
182
-
183
- updateStrokeStyle() {
184
- const material = this._sideMesh?.material as THREE.MeshStandardMaterial
185
- if (!material) {
186
- return
187
- }
188
-
189
- var { strokeStyle } = this.component.state
190
-
191
- material.color.set(strokeStyle)
192
- }
193
-
194
- updateFillStyle() {
195
- var { fillStyle, alpha = 1 } = this.component.state
196
-
197
- var material = this._mainMesh?.material as THREE.MeshStandardMaterial
198
- if (!material) {
199
- return
200
- }
201
-
202
- const texture = RealObject.buildFillStyleTexture(this.component)
203
-
204
- if (texture) {
205
- material.map = texture
206
- } else {
207
- material.color.set(fillStyle)
208
- }
209
- }
210
- }
@@ -1,136 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import * as THREE from 'three'
6
- import { error } from '@hatiolab/things-scene'
7
-
8
- import { RealObject } from './real-object'
9
-
10
- import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
11
- import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'
12
- import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader'
13
- // @ts-ignore
14
- import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js'
15
- import { Properties } from '@hatiolab/things-scene'
16
-
17
- export class RealObjectGLTF extends RealObject {
18
- private static _GLTFLoader = new GLTFLoader()
19
-
20
- private pivot?: THREE.Object3D
21
- private objectSize?: THREE.Vector3 = new THREE.Vector3()
22
-
23
- static get GLTFLoader() {
24
- return RealObjectGLTF._GLTFLoader
25
- }
26
-
27
- build() {
28
- super.build()
29
-
30
- var { src: source } = this.component.state
31
-
32
- if (!source) {
33
- this.clear()
34
- return
35
- }
36
-
37
- let gltfLoader = new GLTFLoader()
38
-
39
- // Optional: Provide a DRACOLoader instance to decode compressed mesh data
40
- const dracoLoader = new DRACOLoader()
41
- dracoLoader.setDecoderPath('/node_modules/three/examples/jsm/libs/draco/')
42
- gltfLoader.setDRACOLoader(dracoLoader)
43
-
44
- const ktx2Loader = new KTX2Loader()
45
- ktx2Loader.setTranscoderPath(`/node_modules/three/examples/jsm/libs/basis/`)
46
- ktx2Loader.detectSupport(this.threeContainer!.renderer3d!)
47
- gltfLoader.setKTX2Loader(ktx2Loader)
48
-
49
- gltfLoader.setMeshoptDecoder(MeshoptDecoder)
50
-
51
- var fullsource = this.component.app.url(source)
52
- gltfLoader.setCrossOrigin('use-credentials')
53
-
54
- gltfLoader.load(
55
- fullsource,
56
- gltf => {
57
- this.gltfLoaded(gltf)
58
- },
59
- xhr => {
60
- console.log(Math.round((xhr.loaded / xhr.total) * 100) + '% loaded')
61
- },
62
- err => {
63
- error('GLTFLoader.load', err)
64
- this.clear()
65
- }
66
- )
67
- }
68
-
69
- private gltfLoaded(gltf: GLTF) {
70
- let scene = gltf.scene
71
-
72
- var animations = gltf.animations
73
- var object = scene.clone()
74
- object.userData.context = this
75
-
76
- object.traverse((child: THREE.Object3D) => {
77
- if ((child as any).isMesh) {
78
- child.castShadow = true
79
- }
80
- })
81
-
82
- var boundingBox = new THREE.Box3().setFromObject(object)
83
- var center = boundingBox.getCenter(object.position)
84
- this.objectSize = boundingBox.getSize(this.objectSize!)
85
-
86
- center.multiplyScalar(-1)
87
-
88
- // 오브젝트 공백을 최소로 하기위해서 clear() 를 최대한 pending함.
89
- this.clear()
90
-
91
- this.pivot = new THREE.Object3D()
92
- this.object3d.add(this.pivot)
93
- this.pivot.add(object)
94
-
95
- this.updateDimension()
96
-
97
- if (animations && animations.length) {
98
- for (var i = 0; i < animations.length; i++) {
99
- var animation = animations[i]
100
- var action = this.threeContainer!.mixer!.clipAction(animation)
101
- action.play()
102
- }
103
- } else {
104
- console.log('no animations..')
105
- }
106
- }
107
-
108
- clear() {
109
- // TODO gltf object 리소스 해제가 필요하면, 여기에 추가.
110
- // 반복적으로 로딩하면 WebGL 리소스 부족으로 오류 발생.
111
-
112
- return super.clear()
113
- }
114
-
115
- updateDimension() {
116
- var { width = 1, height = 1, depth = 1 } = this.component.state
117
-
118
- var { x = 1, y = 1, z = 1 } = this.objectSize || {}
119
-
120
- this.pivot && this.pivot.scale.set(width / x, depth / y, height / z)
121
-
122
- this.component.invalidate()
123
- }
124
-
125
- updateSource() {
126
- this.build()
127
- }
128
-
129
- onchange(after: Properties, before: Properties) {
130
- super.onchange(after, before)
131
-
132
- if ('src' in after) {
133
- this.updateSource()
134
- }
135
- }
136
- }
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import * as THREE from 'three'
5
- import { RealObject } from './real-object'
6
-
7
- export class RealObjectGroup extends RealObject<THREE.Group> {
8
- protected getObject3dInstance() {
9
- return new THREE.Group()
10
- }
11
-
12
- // build() {
13
- // super.build()
14
-
15
- // var { left = 0, top = 0, width = 0, height = 0 } = this.component.bounds
16
-
17
- // let cx = left + width / 2 - canvasSize.width / 2
18
- // let cy = top + height / 2 - canvasSize.height / 2
19
- // // let cz = this.state.rx
20
-
21
- // this.object3d.position.x = cx
22
- // this.object3d.position.z = cy
23
- // }
24
-
25
- // createChildrenObject() {
26
- // var { components } = this._model
27
-
28
- // components.forEach((component: Model) => {
29
- // var item = component.getRealObject()
30
- // if (item) {
31
- // this.object3d.add(item.object3d)
32
- // }
33
- // })
34
- // }
35
- }