@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.
- package/package.json +2 -2
- package/CHANGELOG.md +0 -631
- package/attachments/0d91a37d-c2d7-4c6d-88dc-a29e5bbea361.png +0 -0
- package/attachments/1b07c8d3-07d5-4007-b02e-031ee1755539.glb +0 -0
- package/attachments/226c6c23-c4fd-46c8-93e3-3d3d9c4bb8a9.glb +0 -0
- package/attachments/4425ca46-cf1d-476d-9185-dcb881ecad1f.glb +0 -0
- package/attachments/51e7c45d-6eae-4baf-a4e2-ba979b7e77cd.glb +0 -0
- package/attachments/54427925-c109-4499-875c-fb14207b95c5.glb +0 -0
- package/attachments/8cc70a65-e20f-4187-83c8-64deb3faf3d9.glb +0 -0
- package/attachments/964d004d-1fe7-4224-89a6-2b6e86db233c.glb +0 -0
- package/attachments/ff47fd63-6f1c-4a69-b965-9bb03797a415.png +0 -0
- package/db.sqlite +0 -0
- package/demo/index-modeller.html +0 -112
- package/demo/index.html +0 -109
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -25
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -25
- package/logs/application-2025-01-07-10.log +0 -106
- package/logs/application-2025-01-07-14.log +0 -4
- package/logs/application-2025-01-07-15.log +0 -4
- package/logs/connections-2025-01-07-10.log +0 -106
- package/logs/connections-2025-01-07-14.log +0 -53
- package/logs/connections-2025-01-07-15.log +0 -53
- package/schema.graphql +0 -4552
- package/src/banner.ts +0 -88
- package/src/camera.ts +0 -132
- package/src/component.d.ts +0 -10
- package/src/cube.ts +0 -39
- package/src/cylinder.ts +0 -39
- package/src/desk.ts +0 -135
- package/src/editors/index.ts +0 -13
- package/src/editors/property-editor-gltf-info.ts +0 -135
- package/src/editors/property-editor-location-increase-pattern.ts +0 -260
- package/src/effects/outline.ts +0 -54
- package/src/ellipse.ts +0 -37
- package/src/gltf-object.ts +0 -117
- package/src/html-overlay-element.ts +0 -13
- package/src/index.ts +0 -29
- package/src/light.ts +0 -155
- package/src/polygon.ts +0 -88
- package/src/rack-table-cell.ts +0 -386
- package/src/rack-table.ts +0 -1296
- package/src/rack.ts +0 -232
- package/src/rect.ts +0 -39
- package/src/scene/component.ts +0 -38
- package/src/sphere.ts +0 -39
- package/src/sprite.ts +0 -30
- package/src/stock.ts +0 -262
- package/src/templates/3d-container.ts +0 -21
- package/src/templates/banner.ts +0 -21
- package/src/templates/camera.ts +0 -25
- package/src/templates/cube.ts +0 -20
- package/src/templates/cylinder.ts +0 -20
- package/src/templates/desk.ts +0 -20
- package/src/templates/gltf-object.ts +0 -20
- package/src/templates/index.ts +0 -29
- package/src/templates/light.ts +0 -23
- package/src/templates/pallet.ts +0 -20
- package/src/templates/rack-table.ts +0 -21
- package/src/templates/sphere.ts +0 -20
- package/src/templates/sprite.ts +0 -21
- package/src/templates/visualizer.ts +0 -21
- package/src/templates/wall.ts +0 -20
- package/src/text.ts +0 -10
- package/src/three-container-editor.ts +0 -187
- package/src/three-container.ts +0 -724
- package/src/three-controls.ts +0 -778
- package/src/three-layout.ts +0 -25
- package/src/three-space.ts +0 -732
- package/src/threed/common.ts +0 -21
- package/src/threed/floor/floor.ts +0 -62
- package/src/threed/html/elements.ts +0 -27
- package/src/threed/index.ts +0 -15
- package/src/threed/real-object-camera-meshed.ts +0 -67
- package/src/threed/real-object-camera.ts +0 -41
- package/src/threed/real-object-dom-element.ts +0 -55
- package/src/threed/real-object-dummy.ts +0 -13
- package/src/threed/real-object-extrude.ts +0 -210
- package/src/threed/real-object-gltf.ts +0 -136
- package/src/threed/real-object-group.ts +0 -35
- package/src/threed/real-object-mesh.ts +0 -74
- package/src/threed/real-object-plane.ts +0 -27
- package/src/threed/real-object-scene.ts +0 -84
- package/src/threed/real-object-sprite-2d.ts +0 -54
- package/src/threed/real-object-sprite.ts +0 -64
- package/src/threed/real-object-text.ts +0 -86
- package/src/threed/real-object.ts +0 -326
- package/src/threed/texture/canvas-texture.ts +0 -67
- package/src/threed/texture/text-texture.ts +0 -100
- package/src/threed/three-dimensional-container.ts +0 -9
- package/src/threed/utils/bound-uv-generator.ts +0 -80
- package/src/visualizer.ts +0 -319
- package/src/wall.ts +0 -50
- package/tsconfig.json +0 -24
- package/tsconfig.tsbuildinfo +0 -1
- package/web-dev-server.config.mjs +0 -27
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
|
|
7
|
-
import { applyAlpha } from './common'
|
|
8
|
-
import { RealObject } from './real-object'
|
|
9
|
-
|
|
10
|
-
export abstract class RealObjectMesh extends RealObject<THREE.Mesh> {
|
|
11
|
-
protected getObject3dInstance() {
|
|
12
|
-
return new THREE.Mesh()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
build() {
|
|
16
|
-
super.build()
|
|
17
|
-
|
|
18
|
-
this.buildGeometry()
|
|
19
|
-
this.buildMaterial()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* overide */
|
|
23
|
-
|
|
24
|
-
updateAlpha() {
|
|
25
|
-
var { alpha = 1, fillStyle } = this.component.state
|
|
26
|
-
|
|
27
|
-
applyAlpha(this.object3d.material, alpha, fillStyle)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
updateHidden() {
|
|
31
|
-
this.object3d.visible = !this.component.state.hidden
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
updateFillStyle() {
|
|
35
|
-
var { fillStyle } = this.component.state
|
|
36
|
-
var material = this.object3d.material as THREE.MeshStandardMaterial
|
|
37
|
-
if (!material) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const texture = RealObject.buildFillStyleTexture(this.component)
|
|
42
|
-
|
|
43
|
-
if (texture) {
|
|
44
|
-
texture.needsUpdate = true
|
|
45
|
-
material.map = texture
|
|
46
|
-
} else if (typeof fillStyle == 'string') {
|
|
47
|
-
if (fillStyle !== 'transparent') {
|
|
48
|
-
material.color.set(fillStyle)
|
|
49
|
-
} else {
|
|
50
|
-
material.opacity = 0
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
protected abstract buildGeometry(): void
|
|
56
|
-
|
|
57
|
-
buildMaterial(): void {
|
|
58
|
-
this.object3d.material = new THREE.MeshStandardMaterial({
|
|
59
|
-
transparent: true,
|
|
60
|
-
side: THREE.DoubleSide
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
clear() {
|
|
65
|
-
this.object3d.traverse((mesh: any) => {
|
|
66
|
-
if (mesh.isMesh) {
|
|
67
|
-
mesh.geometry.dispose()
|
|
68
|
-
;(mesh.material.length ? mesh.material : [mesh.material]).forEach((m: any) => m.dispose && m.dispose())
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
return super.clear()
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
Inspired by http://learningthreejs.com/blog/2013/04/30/closing-the-gap-between-html-and-webgl/
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as THREE from 'three'
|
|
10
|
-
|
|
11
|
-
import { RealObjectMesh } from './real-object-mesh'
|
|
12
|
-
|
|
13
|
-
export class RealObjectPlane extends RealObjectMesh {
|
|
14
|
-
buildGeometry() {
|
|
15
|
-
var { width, height } = this.component.state.dimension
|
|
16
|
-
|
|
17
|
-
this.object3d.geometry = new THREE.PlaneGeometry(width, height)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
buildMaterial() /* : THREE.MeshMaterialType | THREE.MeshMaterialType[] */ {
|
|
21
|
-
this.object3d.material = new THREE.MeshStandardMaterial({
|
|
22
|
-
opacity: 0,
|
|
23
|
-
side: THREE.DoubleSide,
|
|
24
|
-
blending: THREE.NoBlending
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,84 +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
|
-
import { createFloor } from './floor/floor'
|
|
9
|
-
|
|
10
|
-
export class RealObjectScene extends RealObject<THREE.Scene> {
|
|
11
|
-
private _floor?: THREE.Mesh
|
|
12
|
-
private _animationMixer?: THREE.AnimationMixer
|
|
13
|
-
|
|
14
|
-
protected getObject3dInstance() {
|
|
15
|
-
return new THREE.Scene()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
dispose() {
|
|
19
|
-
this.object3d.children.forEach(child => {
|
|
20
|
-
;(child as any)['dispose'] && (child as any)['dispose']()
|
|
21
|
-
|
|
22
|
-
this.object3d.remove(child)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
clear() {
|
|
27
|
-
if (this._floor) {
|
|
28
|
-
this.object3d.remove(this._floor)
|
|
29
|
-
|
|
30
|
-
if (this._floor.material instanceof Array) {
|
|
31
|
-
;(this._floor.material as THREE.Material[]).forEach(material => material.dispose())
|
|
32
|
-
} else {
|
|
33
|
-
this._floor.material.dispose()
|
|
34
|
-
}
|
|
35
|
-
this._floor.geometry.dispose()
|
|
36
|
-
|
|
37
|
-
delete this._floor
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return super.clear()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
get floor(): THREE.Mesh {
|
|
44
|
-
return this._floor!
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
set floor(floor: THREE.Mesh | undefined) {
|
|
48
|
-
if (this._floor) {
|
|
49
|
-
this.object3d.remove(this._floor)
|
|
50
|
-
this._floor.clear()
|
|
51
|
-
delete this._floor
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (floor) {
|
|
55
|
-
this._floor = floor
|
|
56
|
-
this.object3d.add(floor)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.component.invalidate()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
build() {
|
|
63
|
-
super.build()
|
|
64
|
-
|
|
65
|
-
this.floor = createFloor(this.component)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
updateTransform() {}
|
|
69
|
-
updateTransformReverse() {}
|
|
70
|
-
updateDimension() {}
|
|
71
|
-
updatePosition() {}
|
|
72
|
-
updateRotate() {}
|
|
73
|
-
updateScale() {}
|
|
74
|
-
updateAlpha() {}
|
|
75
|
-
updateHidden() {}
|
|
76
|
-
|
|
77
|
-
get animationMixer(): THREE.AnimationMixer {
|
|
78
|
-
if (!this._animationMixer) {
|
|
79
|
-
this._animationMixer = new THREE.AnimationMixer(this.object3d)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return this._animationMixer
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import { RealObjectSprite } from './real-object-sprite'
|
|
7
|
-
import { createCanvasTexture } from './texture/canvas-texture'
|
|
8
|
-
|
|
9
|
-
export class RealObjectSprite2D extends RealObjectSprite {
|
|
10
|
-
buildMaterial() {
|
|
11
|
-
var material = this.object3d.material as THREE.SpriteMaterial
|
|
12
|
-
if (material) {
|
|
13
|
-
material.dispose()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
this.object3d.material = new THREE.SpriteMaterial({
|
|
17
|
-
map: createCanvasTexture(this.component),
|
|
18
|
-
alphaTest: 0.01,
|
|
19
|
-
sizeAttenuation: false
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get scale() {
|
|
24
|
-
const { width, height } = this.component.bounds
|
|
25
|
-
const { width: parentWidth, height: parentHeight } = this.threeContainer!.bounds
|
|
26
|
-
const { scale = 1 } = this.component.state
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
x: (scale * width) / parentWidth,
|
|
30
|
-
y: (scale * height) / parentHeight,
|
|
31
|
-
z: scale
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
update() {
|
|
36
|
-
this.build()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
updateFillStyle() {
|
|
40
|
-
this.update()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
updateStrokeStyle() {
|
|
44
|
-
this.update()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
updateAlpha() {
|
|
48
|
-
this.update()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
updateText() {
|
|
52
|
-
this.update()
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import { applyAlpha } from './common'
|
|
7
|
-
import { DELTA } from '@hatiolab/things-scene'
|
|
8
|
-
|
|
9
|
-
import { RealObject } from './real-object'
|
|
10
|
-
|
|
11
|
-
export abstract class RealObjectSprite extends RealObject<THREE.Sprite> {
|
|
12
|
-
protected getObject3dInstance() {
|
|
13
|
-
return new THREE.Sprite()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
build() {
|
|
17
|
-
super.build()
|
|
18
|
-
|
|
19
|
-
this.buildMaterial()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
abstract buildMaterial(): void
|
|
23
|
-
|
|
24
|
-
/* overide */
|
|
25
|
-
|
|
26
|
-
get cz() {
|
|
27
|
-
var { zPos = 0 } = this.component.state
|
|
28
|
-
var { height } = this.component.bounds
|
|
29
|
-
var { tz = 0 } = this.component.delta() as DELTA
|
|
30
|
-
|
|
31
|
-
return zPos + tz + height / 2
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
updateAlpha() {
|
|
35
|
-
var { alpha = 1, fillStyle } = this.component.state
|
|
36
|
-
|
|
37
|
-
applyAlpha(this.object3d.material, alpha, fillStyle)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
updateHidden() {
|
|
41
|
-
this.object3d.visible = !this.component.state.hidden
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
updateFillStyle() {
|
|
45
|
-
var { fillStyle } = this.component.state
|
|
46
|
-
var material = this.object3d.material as THREE.SpriteMaterial
|
|
47
|
-
if (!material) {
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const texture = RealObject.buildFillStyleTexture(this.component)
|
|
52
|
-
|
|
53
|
-
if (texture) {
|
|
54
|
-
texture.needsUpdate = true
|
|
55
|
-
material.map = texture
|
|
56
|
-
} else if (typeof fillStyle == 'string') {
|
|
57
|
-
if (fillStyle !== 'transparent') {
|
|
58
|
-
material.color.set(fillStyle)
|
|
59
|
-
} else {
|
|
60
|
-
material.opacity = 0
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import { applyAlpha } from './common'
|
|
7
|
-
|
|
8
|
-
import { RealObjectMesh } from './real-object-mesh'
|
|
9
|
-
import { textTexture } from './texture/text-texture'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* RealObjectText
|
|
13
|
-
*/
|
|
14
|
-
export class RealObjectText extends RealObjectMesh {
|
|
15
|
-
buildGeometry() {}
|
|
16
|
-
|
|
17
|
-
/* overide */
|
|
18
|
-
|
|
19
|
-
get rotation() {
|
|
20
|
-
const { rotationX = 0, rotationY = 0, rotation = 0 } = this.component.state
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
x: rotationX - Math.PI / 2,
|
|
24
|
-
y: rotationY,
|
|
25
|
-
z: -rotation
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
updateDimension() {
|
|
30
|
-
var { width, height } = this.component.state
|
|
31
|
-
|
|
32
|
-
if (this.object3d.geometry) {
|
|
33
|
-
this.object3d.geometry.dispose()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/* scaling으로 해결되지 않기때문에, 새로 geometry를 만드는 방법을 사용한다 */
|
|
37
|
-
this.object3d.geometry = new THREE.PlaneGeometry(width, height)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
updateText() {
|
|
41
|
-
var material = this.object3d.material as THREE.MeshStandardMaterial
|
|
42
|
-
if (!material) {
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var {
|
|
47
|
-
width,
|
|
48
|
-
height,
|
|
49
|
-
bold = false,
|
|
50
|
-
italic = false,
|
|
51
|
-
fontFamily = 'Serif',
|
|
52
|
-
fontSize = 10,
|
|
53
|
-
fontColor = 'black',
|
|
54
|
-
fillStyle
|
|
55
|
-
} = this.component.state
|
|
56
|
-
|
|
57
|
-
var text = this.component.text
|
|
58
|
-
|
|
59
|
-
const texture = textTexture(text, width, height, {
|
|
60
|
-
bold,
|
|
61
|
-
italic,
|
|
62
|
-
fontFamily,
|
|
63
|
-
fontSize,
|
|
64
|
-
fontColor
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (texture) {
|
|
68
|
-
material.map = texture
|
|
69
|
-
texture.needsUpdate = true
|
|
70
|
-
} else if (typeof fillStyle == 'string') {
|
|
71
|
-
if (fillStyle !== 'transparent') {
|
|
72
|
-
material.color.set(fillStyle)
|
|
73
|
-
} else {
|
|
74
|
-
material.opacity = 0
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
updateAlpha() {
|
|
80
|
-
// material의 transparency는 항상 true으로 유지되어야 한다.
|
|
81
|
-
var { alpha = 1, fontColor } = this.component.state
|
|
82
|
-
|
|
83
|
-
applyAlpha(this.object3d.material, alpha, fontColor)
|
|
84
|
-
;(this.object3d.material as any).transparent = true
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import { Component, Properties, DELTA } from '@hatiolab/things-scene'
|
|
7
|
-
|
|
8
|
-
import { SCALE_MIN } from './common'
|
|
9
|
-
import { ThreeDimensionalContainer } from './three-dimensional-container'
|
|
10
|
-
|
|
11
|
-
function hasProperties(props: string[], obj: object) {
|
|
12
|
-
return props.findIndex(prop => prop in obj) !== -1
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function isIn3DSpace() {
|
|
16
|
-
return true
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
|
|
20
|
-
protected _component: Component
|
|
21
|
-
protected _focused: boolean = false
|
|
22
|
-
|
|
23
|
-
public object3d: T
|
|
24
|
-
|
|
25
|
-
static buildFillStyleTexture(component: Component) {
|
|
26
|
-
const { fillStyle } = component.state
|
|
27
|
-
|
|
28
|
-
if (typeof fillStyle == 'object' && fillStyle.type == 'pattern' && fillStyle.image) {
|
|
29
|
-
return new THREE.TextureLoader(THREE.DefaultLoadingManager).load(
|
|
30
|
-
component.app.url(fillStyle.image),
|
|
31
|
-
texture => {
|
|
32
|
-
texture.minFilter = THREE.LinearFilter
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
texture.colorSpace = THREE.SRGBColorSpace
|
|
35
|
-
texture.repeat.set(1, 1)
|
|
36
|
-
texture.needsUpdate = true
|
|
37
|
-
|
|
38
|
-
component.invalidate()
|
|
39
|
-
},
|
|
40
|
-
e => {
|
|
41
|
-
console.error(e)
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
constructor(component: Component) {
|
|
48
|
-
this._component = component
|
|
49
|
-
this.object3d = this.getObject3dInstance()
|
|
50
|
-
this.component.isIn3DSpace = isIn3DSpace
|
|
51
|
-
|
|
52
|
-
this.component.on('change', this.onchange, this)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
update() {
|
|
56
|
-
this.clear()
|
|
57
|
-
this.build()
|
|
58
|
-
|
|
59
|
-
this.updateDimension()
|
|
60
|
-
this.updateTransform()
|
|
61
|
-
this.updateFillStyle()
|
|
62
|
-
this.updateStrokeStyle()
|
|
63
|
-
this.updateAlpha()
|
|
64
|
-
this.updateHidden()
|
|
65
|
-
this.updateText()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
protected getObject3dInstance(): T {
|
|
69
|
-
return new THREE.Object3D() as T
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
build() {
|
|
73
|
-
this.object3d.userData.context = this
|
|
74
|
-
this.object3d.castShadow = true
|
|
75
|
-
this.object3d.name = this.component.state.id
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get component(): Component {
|
|
79
|
-
return this._component!
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
get threeContainer(): ThreeDimensionalContainer | undefined {
|
|
83
|
-
var component = this.component
|
|
84
|
-
|
|
85
|
-
while (component) {
|
|
86
|
-
if ('is3dContainer' in component && (component as ThreeDimensionalContainer).is3dContainer()) {
|
|
87
|
-
return component as ThreeDimensionalContainer
|
|
88
|
-
}
|
|
89
|
-
component = component.parent
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get focused(): boolean {
|
|
94
|
-
return this._focused
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
set focused(focused: boolean) {
|
|
98
|
-
this._focused = focused
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
dispose() {
|
|
102
|
-
this.component.off('change', this.onchange, this)
|
|
103
|
-
delete this.component._realObject
|
|
104
|
-
|
|
105
|
-
this.clear()
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
clear() {
|
|
109
|
-
this.object3d.children.slice().forEach((child: any) => {
|
|
110
|
-
if (child['dispose']) child['dispose']()
|
|
111
|
-
if (child['geometry'] && child['geometry']['dispose']) child['geometry']['dispose']()
|
|
112
|
-
if (child['material'] && child['material']['dispose']) child['material']['dispose']()
|
|
113
|
-
if (child['texture'] && child['texture']['dispose']) child['texture']['dispose']()
|
|
114
|
-
this.object3d.remove(child)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
this.object3d.userData = {}
|
|
118
|
-
return this.object3d.clear()
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Component의 상태값의 변화를 Object3D에 반영 - translate, rotation, scale
|
|
123
|
-
*/
|
|
124
|
-
updateTransform() {
|
|
125
|
-
// var {
|
|
126
|
-
// scale: { x: sx = 1, y: sy = 1, z: sz = 1 } = UNIT_SCALE,
|
|
127
|
-
// translate: { x: tx = 0, y: ty = 0, z: tz = 0 } = UNIT_TRANSLATE,
|
|
128
|
-
// rotate: { x: rx = 0, y: ry = 0, z: rz = 0 } = UNIT_ROTATE
|
|
129
|
-
// } = this.component.state
|
|
130
|
-
|
|
131
|
-
var { x: tx, y: ty, z: tz } = this.position
|
|
132
|
-
var { x: rx, y: ry, z: rz } = this.rotation
|
|
133
|
-
var { x: sx, y: sy, z: sz } = this.scale
|
|
134
|
-
|
|
135
|
-
this.object3d.position.set(tx, ty, tz)
|
|
136
|
-
this.object3d.rotation.set(rx, ry, rz)
|
|
137
|
-
this.object3d.scale.set(Math.max(sx, SCALE_MIN), Math.max(sy, SCALE_MIN), Math.max(sz, SCALE_MIN))
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
get position() {
|
|
141
|
-
const { x, y, z } = this.center
|
|
142
|
-
return {
|
|
143
|
-
x,
|
|
144
|
-
y: z,
|
|
145
|
-
z: y
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
get rotation() {
|
|
150
|
-
const { rotationX = 0, rotationY = 0, rotation = 0 } = this.component.state
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
x: rotationX,
|
|
154
|
-
y: -rotation,
|
|
155
|
-
z: rotationY
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
get scale() {
|
|
160
|
-
const { scale = 1 } = this.component.state
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
x: scale,
|
|
164
|
-
y: scale,
|
|
165
|
-
z: scale
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
get cx() {
|
|
170
|
-
var { x = 0 } = this.component.center
|
|
171
|
-
var { width: parentWidth = 0 } = this.component.parent.bounds
|
|
172
|
-
var { tx = 0 } = this.component.delta() as DELTA
|
|
173
|
-
|
|
174
|
-
return x + tx - parentWidth / 2
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
get cy() {
|
|
178
|
-
var { y = 0 } = this.component.center
|
|
179
|
-
var { height: parentHeight = 0 } = this.component.parent.bounds
|
|
180
|
-
var { ty = 0 } = this.component.delta() as DELTA
|
|
181
|
-
|
|
182
|
-
return y + ty - parentHeight / 2
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
get cz() {
|
|
186
|
-
var { zPos = 0, depth = 1 } = this.component.state
|
|
187
|
-
var { tz = 0 } = this.component.delta() as DELTA
|
|
188
|
-
|
|
189
|
-
return zPos + tz + depth / 2
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
get center() {
|
|
193
|
-
var { x = 0, y = 0 } = this.component.center
|
|
194
|
-
var { width: parentWidth = 0, height: parentHeight = 0 } = this.component.parent.bounds
|
|
195
|
-
|
|
196
|
-
var { tx = 0, ty = 0, tz = 0 } = this.component.delta() as DELTA
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
x: x + tx - parentWidth / 2,
|
|
200
|
-
y: y + ty - parentHeight / 2,
|
|
201
|
-
z: this.cz
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
get dimension() {
|
|
206
|
-
const { width, height } = this.component.bounds
|
|
207
|
-
const { depth } = this.component.state
|
|
208
|
-
return {
|
|
209
|
-
width,
|
|
210
|
-
height,
|
|
211
|
-
depth
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Object3D 모델의 변화를 Component의 모델값에 반영
|
|
217
|
-
*/
|
|
218
|
-
// updateTransformReverse() {
|
|
219
|
-
// var { rotation, position, scale } = this.object3d
|
|
220
|
-
|
|
221
|
-
// this.component.set({
|
|
222
|
-
// rotate: {
|
|
223
|
-
// x: rotation.x,
|
|
224
|
-
// y: rotation.y,
|
|
225
|
-
// z: rotation.z
|
|
226
|
-
// },
|
|
227
|
-
// translate: {
|
|
228
|
-
// x: position.x,
|
|
229
|
-
// y: position.y,
|
|
230
|
-
// z: position.z
|
|
231
|
-
// },
|
|
232
|
-
// scale: {
|
|
233
|
-
// x: scale.x,
|
|
234
|
-
// y: scale.y,
|
|
235
|
-
// z: scale.z
|
|
236
|
-
// }
|
|
237
|
-
// })
|
|
238
|
-
// }
|
|
239
|
-
|
|
240
|
-
/* update functions - 전체적인 rebuilding이 필요하지 않은 update 기능 들임 */
|
|
241
|
-
updatePosition() {
|
|
242
|
-
var { x = 0, y = 0, z = 0 } = this.position
|
|
243
|
-
this.object3d.position.set(x, y, z)
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
updateRotate() {
|
|
247
|
-
var { x = 0, y = 0, z = 0 } = this.rotation
|
|
248
|
-
this.object3d.rotation.set(x, y, z)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
updateScale() {
|
|
252
|
-
var { x = 1, y = 1, z = 1 } = this.scale
|
|
253
|
-
this.object3d.scale.set(Math.max(x, SCALE_MIN), Math.max(y, SCALE_MIN), Math.max(z, SCALE_MIN))
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
updateDimension() {
|
|
257
|
-
var { width, height, depth } = this.dimension
|
|
258
|
-
this.object3d.scale.set(width, height, depth)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
updateAlpha() {
|
|
262
|
-
var { alpha } = this.component.state
|
|
263
|
-
|
|
264
|
-
alpha = alpha == undefined ? 1 : alpha
|
|
265
|
-
|
|
266
|
-
this.object3d.traverse((o: any) => {
|
|
267
|
-
var materials = o.material
|
|
268
|
-
if (!o.material) return
|
|
269
|
-
|
|
270
|
-
if (!Array.isArray(materials)) {
|
|
271
|
-
materials = [materials]
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
materials.forEach((m: any) => {
|
|
275
|
-
m.opacity *= alpha
|
|
276
|
-
m.transparent = alpha < 1
|
|
277
|
-
})
|
|
278
|
-
})
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
updateHidden() {
|
|
282
|
-
this.object3d.visible = !this.component.state.hidden
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
updateStrokeStyle() {}
|
|
286
|
-
updateFillStyle() {}
|
|
287
|
-
updateText() {}
|
|
288
|
-
|
|
289
|
-
onchange(after: Properties, before: Properties) {
|
|
290
|
-
if (hasProperties(['cx', 'cy', 'cz', 'zPos', 'left', 'top'], after)) {
|
|
291
|
-
this.updatePosition()
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (hasProperties(['width', 'height', 'depth'], after)) {
|
|
295
|
-
this.updateDimension()
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (hasProperties(['rotationX', 'rotationY', 'rotation'], after)) {
|
|
299
|
-
this.updateRotate()
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if ('scale' in after) {
|
|
303
|
-
this.updateScale()
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if ('hidden' in after) {
|
|
307
|
-
this.updateHidden()
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if ('alpha' in after) {
|
|
311
|
-
this.updateAlpha()
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if ('strokeStyle' in after) {
|
|
315
|
-
this.updateStrokeStyle()
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if ('fillStyle' in after) {
|
|
319
|
-
this.updateFillStyle()
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if ('text' in after) {
|
|
323
|
-
this.updateText()
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|