@operato/scene-visualizer 1.2.12 → 1.2.14
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/CHANGELOG.md +19 -0
- package/db.sqlite +0 -0
- package/dist/cube.d.ts +1 -3
- package/dist/cube.js +1 -5
- package/dist/cube.js.map +1 -1
- package/dist/cylinder.d.ts +1 -3
- package/dist/cylinder.js +1 -5
- package/dist/cylinder.js.map +1 -1
- package/dist/rack.js +3 -3
- package/dist/rack.js.map +1 -1
- package/dist/sphere.d.ts +1 -3
- package/dist/sphere.js +1 -8
- package/dist/sphere.js.map +1 -1
- package/dist/sprite.js +0 -6
- package/dist/sprite.js.map +1 -1
- package/dist/stock.d.ts +7 -2
- package/dist/stock.js +8 -4
- package/dist/stock.js.map +1 -1
- package/dist/threed/common.js +3 -2
- package/dist/threed/common.js.map +1 -1
- package/dist/threed/real-object-camera-meshed.d.ts +1 -1
- package/dist/threed/real-object-camera-meshed.js +1 -1
- package/dist/threed/real-object-camera-meshed.js.map +1 -1
- package/dist/threed/real-object-dom-element.d.ts +0 -3
- package/dist/threed/real-object-dom-element.js +0 -51
- package/dist/threed/real-object-dom-element.js.map +1 -1
- package/dist/threed/real-object-extrude.d.ts +2 -3
- package/dist/threed/real-object-extrude.js +27 -66
- package/dist/threed/real-object-extrude.js.map +1 -1
- package/dist/threed/real-object-gltf.d.ts +0 -2
- package/dist/threed/real-object-gltf.js +2 -8
- package/dist/threed/real-object-gltf.js.map +1 -1
- package/dist/threed/real-object-mesh.d.ts +3 -2
- package/dist/threed/real-object-mesh.js +22 -13
- package/dist/threed/real-object-mesh.js.map +1 -1
- package/dist/threed/real-object-plane.d.ts +2 -3
- package/dist/threed/real-object-plane.js +6 -7
- package/dist/threed/real-object-plane.js.map +1 -1
- package/dist/threed/real-object-sprite-2d.d.ts +2 -2
- package/dist/threed/real-object-sprite-2d.js +12 -9
- package/dist/threed/real-object-sprite-2d.js.map +1 -1
- package/dist/threed/real-object-sprite.d.ts +4 -1
- package/dist/threed/real-object-sprite.js +30 -1
- package/dist/threed/real-object-sprite.js.map +1 -1
- package/dist/threed/real-object-text.d.ts +3 -4
- package/dist/threed/real-object-text.js +41 -47
- package/dist/threed/real-object-text.js.map +1 -1
- package/dist/threed/real-object.d.ts +0 -1
- package/dist/threed/real-object.js +14 -18
- package/dist/threed/real-object.js.map +1 -1
- package/dist/threed/texture/canvas-texture.js +3 -1
- package/dist/threed/texture/canvas-texture.js.map +1 -1
- package/dist/wall.d.ts +2 -3
- package/dist/wall.js +4 -5
- package/dist/wall.js.map +1 -1
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +6 -21
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +10 -0
- package/logs/application-2023-03-05-12.log +6 -0
- package/logs/application-2023-03-05-23.log +12 -0
- package/logs/connections-2023-03-05-12.log +35 -0
- package/logs/connections-2023-03-05-23.log +70 -0
- package/package.json +2 -2
- package/src/cube.ts +1 -7
- package/src/cylinder.ts +1 -7
- package/src/rack.ts +3 -4
- package/src/sphere.ts +1 -10
- package/src/sprite.ts +0 -8
- package/src/stock.ts +9 -6
- package/src/threed/common.ts +3 -2
- package/src/threed/real-object-camera-meshed.ts +1 -1
- package/src/threed/real-object-dom-element.ts +0 -71
- package/src/threed/real-object-extrude.ts +31 -69
- package/src/threed/real-object-gltf.ts +2 -10
- package/src/threed/real-object-mesh.ts +21 -14
- package/src/threed/real-object-plane.ts +6 -9
- package/src/threed/real-object-sprite-2d.ts +15 -12
- package/src/threed/real-object-sprite.ts +36 -2
- package/src/threed/real-object-text.ts +49 -60
- package/src/threed/real-object.ts +15 -22
- package/src/threed/texture/canvas-texture.ts +3 -1
- package/src/wall.ts +5 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/logs/application-2023-03-01-03.log +0 -6
- package/logs/application-2023-03-01-13.log +0 -6
- package/logs/application-2023-03-01-15.log +0 -6
- package/logs/application-2023-03-03-00.log +0 -25
- package/logs/application-2023-03-03-01.log +0 -6
package/src/sphere.ts
CHANGED
|
@@ -18,16 +18,7 @@ export class Sphere3D extends RealObjectMesh {
|
|
|
18
18
|
buildGeometry() {
|
|
19
19
|
var { rx = 0 } = this.component.state
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
buildMaterial() {
|
|
25
|
-
var { fillStyle = 'gray' } = this.component.state
|
|
26
|
-
|
|
27
|
-
return new THREE.MeshStandardMaterial({
|
|
28
|
-
color: fillStyle,
|
|
29
|
-
side: THREE.FrontSide
|
|
30
|
-
})
|
|
21
|
+
this.object3d.geometry = new THREE.SphereGeometry(rx, 20, 20)
|
|
31
22
|
}
|
|
32
23
|
}
|
|
33
24
|
|
package/src/sprite.ts
CHANGED
|
@@ -22,14 +22,6 @@ export class Sprite extends RectPath(Shape) {
|
|
|
22
22
|
return new RealObjectSprite2D(this)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// ready() {
|
|
26
|
-
// super.ready()
|
|
27
|
-
|
|
28
|
-
// setInterval(() => {
|
|
29
|
-
// this.text = String(Math.random())
|
|
30
|
-
// }, 1000)
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
25
|
get nature() {
|
|
34
26
|
return NATURE
|
|
35
27
|
}
|
package/src/stock.ts
CHANGED
|
@@ -32,10 +32,6 @@ export class Stock extends RealObject<THREE.Mesh> {
|
|
|
32
32
|
return new THREE.Mesh()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
updateTransform() {
|
|
36
|
-
// intentionally empty. important!
|
|
37
|
-
}
|
|
38
|
-
|
|
39
35
|
getMaterial(index: number) {
|
|
40
36
|
var visualizer = this.visualizer
|
|
41
37
|
|
|
@@ -157,8 +153,6 @@ export class Stock extends RealObject<THREE.Mesh> {
|
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
155
|
|
|
160
|
-
updateAlpha() {}
|
|
161
|
-
|
|
162
156
|
onchangeStockData(data: any) {
|
|
163
157
|
var visualizer = this.visualizer
|
|
164
158
|
|
|
@@ -256,4 +250,13 @@ export class Stock extends RealObject<THREE.Mesh> {
|
|
|
256
250
|
})
|
|
257
251
|
}
|
|
258
252
|
}
|
|
253
|
+
|
|
254
|
+
// all update functions should be intentionally empty. important!
|
|
255
|
+
updateTransform() {}
|
|
256
|
+
updateDimension() {}
|
|
257
|
+
updateAlpha() {}
|
|
258
|
+
updateFillStyle() {}
|
|
259
|
+
updateStrokeStyle() {}
|
|
260
|
+
updateHidden() {}
|
|
261
|
+
updateText() {}
|
|
259
262
|
}
|
package/src/threed/common.ts
CHANGED
|
@@ -4,14 +4,15 @@ export const SCALE_MIN = 0.001
|
|
|
4
4
|
|
|
5
5
|
export function applyAlpha(material: any, alpha: number, fillStyle: any) {
|
|
6
6
|
var opacity = 1
|
|
7
|
-
if (!fillStyle || fillStyle == 'none') {
|
|
8
|
-
opacity =
|
|
7
|
+
if (!fillStyle || fillStyle == 'none' || fillStyle == 'transparent') {
|
|
8
|
+
opacity = 0
|
|
9
9
|
} else {
|
|
10
10
|
var fillAlpha = typeof fillStyle == 'string' ? tinycolor(fillStyle).getAlpha() : 1
|
|
11
11
|
opacity = alpha * fillAlpha
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
material.opacity = opacity
|
|
15
|
+
material.transparent = opacity < 1
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const UNIT_DIMENSION = { width: 1, height: 1, depth: 1 }
|
|
@@ -15,32 +15,6 @@ export class RealObjectDomElement extends RealObject<CSS3DObject> {
|
|
|
15
15
|
return new CSS3DObject((this.component as HTMLOverlayElement | HTMLOverlayContainer).element)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// private _cssObject3d?: THREE.Object3D
|
|
19
|
-
|
|
20
|
-
// buildGeometry() {
|
|
21
|
-
// var { width, height } = this.component.bounds
|
|
22
|
-
|
|
23
|
-
// return new THREE.PlaneGeometry(width, height)
|
|
24
|
-
// }
|
|
25
|
-
|
|
26
|
-
// buildMaterial() /* : THREE.MeshMaterialType | THREE.MeshMaterialType[] */ {
|
|
27
|
-
// var material = new THREE.MeshBasicMaterial()
|
|
28
|
-
|
|
29
|
-
// material.color.set('black')
|
|
30
|
-
// material.opacity = 0
|
|
31
|
-
// material.side = THREE.DoubleSide
|
|
32
|
-
// material.blending = THREE.NoBlending
|
|
33
|
-
|
|
34
|
-
// return material
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
// get cssObject3d(): THREE.Object3D {
|
|
38
|
-
// if (!this._cssObject3d) {
|
|
39
|
-
// this._cssObject3d = this.buildCSS3DObject()
|
|
40
|
-
// }
|
|
41
|
-
// return this._cssObject3d
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
18
|
build() {
|
|
45
19
|
super.build()
|
|
46
20
|
|
|
@@ -53,53 +27,8 @@ export class RealObjectDomElement extends RealObject<CSS3DObject> {
|
|
|
53
27
|
|
|
54
28
|
element.style.left = ''
|
|
55
29
|
element.style.top = ''
|
|
56
|
-
|
|
57
|
-
// this.object3d.add()
|
|
58
|
-
|
|
59
|
-
// const cssobj = new CSS3DObject(element)
|
|
60
|
-
// cssobj.position.set(-1, -1, 0)
|
|
61
|
-
|
|
62
|
-
// this.object3d.add(cssobj)
|
|
63
|
-
|
|
64
|
-
// return cssobj
|
|
65
30
|
}
|
|
66
31
|
|
|
67
|
-
/**
|
|
68
|
-
* Component의 상태값의 변화를 Object3D에 반영 - translate, rotation, scale
|
|
69
|
-
*/
|
|
70
|
-
// updateTransform() {
|
|
71
|
-
// super.updateTransform()
|
|
72
|
-
|
|
73
|
-
// var { x: tx, y: ty, z: tz } = this.position
|
|
74
|
-
// var { x: rx, y: ry, z: rz } = this.rotation
|
|
75
|
-
// var { x: sx, y: sy, z: sz } = this.scale
|
|
76
|
-
|
|
77
|
-
// this.cssObject3d.position.set(tx, ty, tz)
|
|
78
|
-
// this.cssObject3d.rotation.set(rx, ry, rz)
|
|
79
|
-
// this.cssObject3d.scale.set(Math.max(sx, SCALE_MIN), Math.max(sy, SCALE_MIN), Math.max(sz, SCALE_MIN))
|
|
80
|
-
// }
|
|
81
|
-
|
|
82
|
-
// updatePosition() {
|
|
83
|
-
// super.updatePosition()
|
|
84
|
-
|
|
85
|
-
// var { x: tx, y: ty, z: tz } = this.position
|
|
86
|
-
// this.cssObject3d.position.set(tx, ty, tz)
|
|
87
|
-
// }
|
|
88
|
-
|
|
89
|
-
// updateRotate() {
|
|
90
|
-
// super.updateRotate()
|
|
91
|
-
|
|
92
|
-
// var { x: rx, y: ry, z: rz } = this.rotation
|
|
93
|
-
// this.cssObject3d.rotation.set(rx, ry, rz)
|
|
94
|
-
// }
|
|
95
|
-
|
|
96
|
-
// updateScale() {
|
|
97
|
-
// super.updateScale()
|
|
98
|
-
|
|
99
|
-
// var { x: sx, y: sy, z: sz } = this.scale
|
|
100
|
-
// this.cssObject3d.scale.set(Math.max(sx, SCALE_MIN), Math.max(sy, SCALE_MIN), Math.max(sz, SCALE_MIN))
|
|
101
|
-
// }
|
|
102
|
-
|
|
103
32
|
updateDimension() {
|
|
104
33
|
super.updateDimension()
|
|
105
34
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as THREE from 'three'
|
|
6
|
-
import tinycolor from 'tinycolor2'
|
|
7
6
|
|
|
8
7
|
import { RealObject } from './real-object'
|
|
9
8
|
|
|
@@ -33,7 +32,7 @@ export class RealObjectExtrude extends RealObject {
|
|
|
33
32
|
build() {
|
|
34
33
|
super.build()
|
|
35
34
|
|
|
36
|
-
var { depth = 1
|
|
35
|
+
var { depth = 1 } = this.component.state
|
|
37
36
|
|
|
38
37
|
// 다각형 그리기
|
|
39
38
|
var shape = this.shape
|
|
@@ -54,20 +53,19 @@ export class RealObjectExtrude extends RealObject {
|
|
|
54
53
|
|
|
55
54
|
var geometry = this.createGeometry(shape)
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this._mainMesh.castShadow = true
|
|
56
|
+
var material = this.createMainMaterial()
|
|
57
|
+
this._mainMesh = this.createMainMesh(geometry, material as THREE.Material)
|
|
58
|
+
this._mainMesh.castShadow = true
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
}
|
|
60
|
+
this.object3d.add(this._mainMesh)
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this._sideMesh.castShadow = true
|
|
62
|
+
this._sideMesh = this.createSideMesh(geometry, shape /* FIXME , extrudeSettings */)
|
|
63
|
+
this._sideMesh.castShadow = true
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
this.object3d.add(this._sideMesh)
|
|
66
|
+
|
|
67
|
+
this.updateFillStyle()
|
|
68
|
+
this.updateStrokeStyle()
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
createGeometry(shape: THREE.Shape): THREE.BufferGeometry {
|
|
@@ -86,37 +84,14 @@ export class RealObjectExtrude extends RealObject {
|
|
|
86
84
|
return geometry as any
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
var { fillStyle = 'black', alpha = 1 } = this.component.state
|
|
91
|
-
|
|
92
|
-
var params = {} as any
|
|
93
|
-
var opacity = alpha
|
|
94
|
-
const texture = RealObject.buildFillStyleTexture(this.component)
|
|
95
|
-
|
|
96
|
-
if (texture) {
|
|
97
|
-
params = {
|
|
98
|
-
map: texture,
|
|
99
|
-
side: THREE.FrontSide
|
|
100
|
-
}
|
|
101
|
-
} else if (typeof fillStyle == 'string') {
|
|
102
|
-
if (fillStyle !== 'transparent') {
|
|
103
|
-
params.color = fillStyle
|
|
104
|
-
opacity *= tinycolor(fillStyle).getAlpha()
|
|
105
|
-
} else {
|
|
106
|
-
opacity = 0
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
87
|
+
createMainMaterial() {
|
|
110
88
|
return new THREE.MeshStandardMaterial({
|
|
111
|
-
...params,
|
|
112
|
-
opacity,
|
|
113
|
-
transparent: opacity < 1,
|
|
114
89
|
metalness: 0.5,
|
|
115
90
|
roughness: 0.5
|
|
116
91
|
})
|
|
117
92
|
}
|
|
118
93
|
|
|
119
|
-
|
|
94
|
+
createMainMesh(geometry: THREE.BufferGeometry, material: THREE.Material) {
|
|
120
95
|
var mesh = new THREE.Mesh(geometry, material)
|
|
121
96
|
mesh.rotation.x = -Math.PI / 2
|
|
122
97
|
mesh.rotation.y = -Math.PI
|
|
@@ -126,26 +101,19 @@ export class RealObjectExtrude extends RealObject {
|
|
|
126
101
|
}
|
|
127
102
|
|
|
128
103
|
createSideMesh(geometry: THREE.BufferGeometry, shape: THREE.Shape) {
|
|
129
|
-
var {
|
|
104
|
+
var { depth = 1, lineWidth = 0 } = this.component.state
|
|
130
105
|
|
|
131
106
|
var hole = new THREE.Path()
|
|
132
107
|
hole.setFromPoints(shape.getPoints())
|
|
133
108
|
|
|
134
109
|
var sideMaterial = new THREE.MeshStandardMaterial({
|
|
135
|
-
color: strokeStyle,
|
|
136
110
|
metalness: 0.5,
|
|
137
|
-
roughness: 0.5
|
|
111
|
+
roughness: 0.5,
|
|
112
|
+
// prevent overlapped layers flickering
|
|
113
|
+
polygonOffset: true,
|
|
114
|
+
polygonOffsetFactor: -0.1
|
|
138
115
|
})
|
|
139
116
|
|
|
140
|
-
var tinyStrokeStyle = tinycolor(strokeStyle)
|
|
141
|
-
var strokeAlpha = tinyStrokeStyle.getAlpha()
|
|
142
|
-
sideMaterial.opacity = alpha * strokeAlpha
|
|
143
|
-
sideMaterial.transparent = alpha < 1 || strokeAlpha < 1
|
|
144
|
-
|
|
145
|
-
// prevent overlapped layers flickering
|
|
146
|
-
sideMaterial.polygonOffset = true
|
|
147
|
-
sideMaterial.polygonOffsetFactor = -0.1
|
|
148
|
-
|
|
149
117
|
shape = this.sideShape || shape
|
|
150
118
|
shape.holes.push(hole)
|
|
151
119
|
|
|
@@ -187,7 +155,6 @@ export class RealObjectExtrude extends RealObject {
|
|
|
187
155
|
|
|
188
156
|
var { width, height } = this.component.bounds
|
|
189
157
|
|
|
190
|
-
// TODO component.text의 heavy한 로직을 반복적으로 실행하지 않도록, 캐싱하자.
|
|
191
158
|
var poweredWidth = nextPowerOf2(width)
|
|
192
159
|
var poweredHeight = nextPowerOf2(height)
|
|
193
160
|
|
|
@@ -207,23 +174,27 @@ export class RealObjectExtrude extends RealObject {
|
|
|
207
174
|
}
|
|
208
175
|
|
|
209
176
|
updateAlpha() {
|
|
210
|
-
var { alpha = 1, fillStyle,
|
|
177
|
+
var { alpha = 1, fillStyle, strokeStyle } = this.component.state
|
|
211
178
|
|
|
212
179
|
this._mainMesh && applyAlpha(this._mainMesh.material, alpha, fillStyle)
|
|
213
|
-
this._sideMesh && applyAlpha(this._sideMesh.material, alpha,
|
|
180
|
+
this._sideMesh && applyAlpha(this._sideMesh.material, alpha, strokeStyle)
|
|
214
181
|
}
|
|
215
182
|
|
|
216
183
|
updateStrokeStyle() {
|
|
184
|
+
const material = this._sideMesh?.material as THREE.MeshStandardMaterial
|
|
185
|
+
if (!material) {
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
|
|
217
189
|
var { strokeStyle } = this.component.state
|
|
218
190
|
|
|
219
|
-
|
|
220
|
-
;(this._sideMesh?.material as THREE.MeshStandardMaterial).color.set(strokeStyle)
|
|
221
|
-
}
|
|
191
|
+
material.color.set(strokeStyle)
|
|
222
192
|
}
|
|
223
193
|
|
|
224
194
|
updateFillStyle() {
|
|
225
|
-
var { fillStyle } = this.component.state
|
|
226
|
-
|
|
195
|
+
var { fillStyle, alpha = 1 } = this.component.state
|
|
196
|
+
|
|
197
|
+
var material = this._mainMesh?.material as THREE.MeshStandardMaterial
|
|
227
198
|
if (!material) {
|
|
228
199
|
return
|
|
229
200
|
}
|
|
@@ -232,17 +203,8 @@ export class RealObjectExtrude extends RealObject {
|
|
|
232
203
|
|
|
233
204
|
if (texture) {
|
|
234
205
|
material.map = texture
|
|
235
|
-
} else
|
|
236
|
-
|
|
237
|
-
material.color.set(fillStyle)
|
|
238
|
-
} else {
|
|
239
|
-
// material.color.set(fillStyle)
|
|
240
|
-
material.opacity = 0
|
|
241
|
-
}
|
|
206
|
+
} else {
|
|
207
|
+
material.color.set(fillStyle)
|
|
242
208
|
}
|
|
243
209
|
}
|
|
244
|
-
|
|
245
|
-
get rebuildingProperties(): string[] {
|
|
246
|
-
return ['width', 'height', 'depth', 'text', 'path']
|
|
247
|
-
}
|
|
248
210
|
}
|
|
@@ -91,7 +91,7 @@ export class RealObjectGLTF extends RealObject {
|
|
|
91
91
|
this.object3d.add(this.pivot)
|
|
92
92
|
this.pivot.add(object)
|
|
93
93
|
|
|
94
|
-
this.
|
|
94
|
+
this.updateDimension()
|
|
95
95
|
|
|
96
96
|
if (animations && animations.length) {
|
|
97
97
|
for (var i = 0; i < animations.length; i++) {
|
|
@@ -111,7 +111,7 @@ export class RealObjectGLTF extends RealObject {
|
|
|
111
111
|
return super.clear()
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
updateDimension() {
|
|
115
115
|
var { width = 1, height = 1, depth = 1 } = this.component.state
|
|
116
116
|
|
|
117
117
|
var { x = 1, y = 1, z = 1 } = this.objectSize || {}
|
|
@@ -120,12 +120,4 @@ export class RealObjectGLTF extends RealObject {
|
|
|
120
120
|
|
|
121
121
|
this.component.invalidate()
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
updateDimension() {
|
|
125
|
-
this._rescale()
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
get rebuildingProperties(): string[] {
|
|
129
|
-
return ['fillStyle', 'lineStyle', 'text']
|
|
130
|
-
}
|
|
131
123
|
}
|
|
@@ -15,8 +15,8 @@ export abstract class RealObjectMesh extends RealObject<THREE.Mesh> {
|
|
|
15
15
|
build() {
|
|
16
16
|
super.build()
|
|
17
17
|
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
18
|
+
this.buildGeometry()
|
|
19
|
+
this.buildMaterial()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/* overide */
|
|
@@ -31,27 +31,34 @@ export abstract class RealObjectMesh extends RealObject<THREE.Mesh> {
|
|
|
31
31
|
this.object3d.visible = !this.component.state.hidden
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
buildMaterial(): THREE.Material {
|
|
34
|
+
updateFillStyle() {
|
|
37
35
|
var { fillStyle } = this.component.state
|
|
36
|
+
var material = this.object3d.material as THREE.MeshStandardMaterial
|
|
37
|
+
if (!material) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
38
40
|
|
|
39
|
-
var params: any = {}
|
|
40
41
|
const texture = RealObject.buildFillStyleTexture(this.component)
|
|
41
42
|
|
|
42
43
|
if (texture) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
}
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
protected abstract buildGeometry(): void
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
buildMaterial(): void {
|
|
58
|
+
this.object3d.material = new THREE.MeshStandardMaterial({
|
|
59
|
+
transparent: true,
|
|
60
|
+
side: THREE.DoubleSide
|
|
61
|
+
})
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
clear() {
|
|
@@ -14,17 +14,14 @@ export class RealObjectPlane extends RealObjectMesh {
|
|
|
14
14
|
buildGeometry() {
|
|
15
15
|
var { width, height } = this.component.state.dimension
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
this.object3d.geometry = new THREE.PlaneGeometry(width, height)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
buildMaterial() /* : THREE.MeshMaterialType | THREE.MeshMaterialType[] */ {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
material.blending = THREE.NoBlending
|
|
27
|
-
|
|
28
|
-
return material
|
|
21
|
+
this.object3d.material = new THREE.MeshStandardMaterial({
|
|
22
|
+
opacity: 0,
|
|
23
|
+
side: THREE.DoubleSide,
|
|
24
|
+
blending: THREE.NoBlending
|
|
25
|
+
})
|
|
29
26
|
}
|
|
30
27
|
}
|
|
@@ -7,18 +7,7 @@ import { RealObjectSprite } from './real-object-sprite'
|
|
|
7
7
|
import { createCanvasTexture } from './texture/canvas-texture'
|
|
8
8
|
|
|
9
9
|
export class RealObjectSprite2D extends RealObjectSprite {
|
|
10
|
-
buildMaterial() {
|
|
11
|
-
var { fillStyle } = this.component.state
|
|
12
|
-
|
|
13
|
-
var material = new THREE.SpriteMaterial({
|
|
14
|
-
map: createCanvasTexture(this.component),
|
|
15
|
-
alphaTest: 0.1
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
material.sizeAttenuation = false
|
|
19
|
-
|
|
20
|
-
return material
|
|
21
|
-
}
|
|
10
|
+
buildMaterial() {}
|
|
22
11
|
|
|
23
12
|
get scale() {
|
|
24
13
|
const { width, height } = this.component.bounds
|
|
@@ -31,4 +20,18 @@ export class RealObjectSprite2D extends RealObjectSprite {
|
|
|
31
20
|
z: scale
|
|
32
21
|
}
|
|
33
22
|
}
|
|
23
|
+
|
|
24
|
+
updateFillStyle() {
|
|
25
|
+
var material = this.object3d.material as THREE.SpriteMaterial
|
|
26
|
+
if (material) {
|
|
27
|
+
material.dispose()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.object3d.material = new THREE.SpriteMaterial({
|
|
31
|
+
map: createCanvasTexture(this.component),
|
|
32
|
+
alphaTest: 0.1
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
this.object3d.material.sizeAttenuation = false
|
|
36
|
+
}
|
|
34
37
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as THREE from 'three'
|
|
6
|
+
import { applyAlpha } from './common'
|
|
6
7
|
|
|
7
8
|
import { RealObject } from './real-object'
|
|
8
9
|
|
|
@@ -14,8 +15,41 @@ export abstract class RealObjectSprite extends RealObject<THREE.Sprite> {
|
|
|
14
15
|
build() {
|
|
15
16
|
super.build()
|
|
16
17
|
|
|
17
|
-
this.
|
|
18
|
+
this.buildMaterial()
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
abstract buildMaterial():
|
|
21
|
+
abstract buildMaterial(): void
|
|
22
|
+
|
|
23
|
+
/* overide */
|
|
24
|
+
|
|
25
|
+
updateAlpha() {
|
|
26
|
+
var { alpha = 1, fillStyle } = this.component.state
|
|
27
|
+
|
|
28
|
+
applyAlpha(this.object3d.material, alpha, fillStyle)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateHidden() {
|
|
32
|
+
this.object3d.visible = !this.component.state.hidden
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
updateFillStyle() {
|
|
36
|
+
var { fillStyle } = this.component.state
|
|
37
|
+
var material = this.object3d.material as THREE.SpriteMaterial
|
|
38
|
+
if (!material) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const texture = RealObject.buildFillStyleTexture(this.component)
|
|
43
|
+
|
|
44
|
+
if (texture) {
|
|
45
|
+
texture.needsUpdate = true
|
|
46
|
+
material.map = texture
|
|
47
|
+
} else if (typeof fillStyle == 'string') {
|
|
48
|
+
if (fillStyle !== 'transparent') {
|
|
49
|
+
material.color.set(fillStyle)
|
|
50
|
+
} else {
|
|
51
|
+
material.opacity = 0
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
21
55
|
}
|