@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.
Files changed (87) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/db.sqlite +0 -0
  3. package/dist/cube.d.ts +1 -3
  4. package/dist/cube.js +1 -5
  5. package/dist/cube.js.map +1 -1
  6. package/dist/cylinder.d.ts +1 -3
  7. package/dist/cylinder.js +1 -5
  8. package/dist/cylinder.js.map +1 -1
  9. package/dist/rack.js +3 -3
  10. package/dist/rack.js.map +1 -1
  11. package/dist/sphere.d.ts +1 -3
  12. package/dist/sphere.js +1 -8
  13. package/dist/sphere.js.map +1 -1
  14. package/dist/sprite.js +0 -6
  15. package/dist/sprite.js.map +1 -1
  16. package/dist/stock.d.ts +7 -2
  17. package/dist/stock.js +8 -4
  18. package/dist/stock.js.map +1 -1
  19. package/dist/threed/common.js +3 -2
  20. package/dist/threed/common.js.map +1 -1
  21. package/dist/threed/real-object-camera-meshed.d.ts +1 -1
  22. package/dist/threed/real-object-camera-meshed.js +1 -1
  23. package/dist/threed/real-object-camera-meshed.js.map +1 -1
  24. package/dist/threed/real-object-dom-element.d.ts +0 -3
  25. package/dist/threed/real-object-dom-element.js +0 -51
  26. package/dist/threed/real-object-dom-element.js.map +1 -1
  27. package/dist/threed/real-object-extrude.d.ts +2 -3
  28. package/dist/threed/real-object-extrude.js +27 -66
  29. package/dist/threed/real-object-extrude.js.map +1 -1
  30. package/dist/threed/real-object-gltf.d.ts +0 -2
  31. package/dist/threed/real-object-gltf.js +2 -8
  32. package/dist/threed/real-object-gltf.js.map +1 -1
  33. package/dist/threed/real-object-mesh.d.ts +3 -2
  34. package/dist/threed/real-object-mesh.js +22 -13
  35. package/dist/threed/real-object-mesh.js.map +1 -1
  36. package/dist/threed/real-object-plane.d.ts +2 -3
  37. package/dist/threed/real-object-plane.js +6 -7
  38. package/dist/threed/real-object-plane.js.map +1 -1
  39. package/dist/threed/real-object-sprite-2d.d.ts +2 -2
  40. package/dist/threed/real-object-sprite-2d.js +12 -9
  41. package/dist/threed/real-object-sprite-2d.js.map +1 -1
  42. package/dist/threed/real-object-sprite.d.ts +4 -1
  43. package/dist/threed/real-object-sprite.js +30 -1
  44. package/dist/threed/real-object-sprite.js.map +1 -1
  45. package/dist/threed/real-object-text.d.ts +3 -4
  46. package/dist/threed/real-object-text.js +41 -47
  47. package/dist/threed/real-object-text.js.map +1 -1
  48. package/dist/threed/real-object.d.ts +0 -1
  49. package/dist/threed/real-object.js +14 -18
  50. package/dist/threed/real-object.js.map +1 -1
  51. package/dist/threed/texture/canvas-texture.js +3 -1
  52. package/dist/threed/texture/canvas-texture.js.map +1 -1
  53. package/dist/wall.d.ts +2 -3
  54. package/dist/wall.js +4 -5
  55. package/dist/wall.js.map +1 -1
  56. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +6 -21
  57. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +10 -0
  58. package/logs/application-2023-03-05-12.log +6 -0
  59. package/logs/application-2023-03-05-23.log +12 -0
  60. package/logs/connections-2023-03-05-12.log +35 -0
  61. package/logs/connections-2023-03-05-23.log +70 -0
  62. package/package.json +2 -2
  63. package/src/cube.ts +1 -7
  64. package/src/cylinder.ts +1 -7
  65. package/src/rack.ts +3 -4
  66. package/src/sphere.ts +1 -10
  67. package/src/sprite.ts +0 -8
  68. package/src/stock.ts +9 -6
  69. package/src/threed/common.ts +3 -2
  70. package/src/threed/real-object-camera-meshed.ts +1 -1
  71. package/src/threed/real-object-dom-element.ts +0 -71
  72. package/src/threed/real-object-extrude.ts +31 -69
  73. package/src/threed/real-object-gltf.ts +2 -10
  74. package/src/threed/real-object-mesh.ts +21 -14
  75. package/src/threed/real-object-plane.ts +6 -9
  76. package/src/threed/real-object-sprite-2d.ts +15 -12
  77. package/src/threed/real-object-sprite.ts +36 -2
  78. package/src/threed/real-object-text.ts +49 -60
  79. package/src/threed/real-object.ts +15 -22
  80. package/src/threed/texture/canvas-texture.ts +3 -1
  81. package/src/wall.ts +5 -6
  82. package/tsconfig.tsbuildinfo +1 -1
  83. package/logs/application-2023-03-01-03.log +0 -6
  84. package/logs/application-2023-03-01-13.log +0 -6
  85. package/logs/application-2023-03-01-15.log +0 -6
  86. package/logs/application-2023-03-03-00.log +0 -25
  87. package/logs/application-2023-03-03-01.log +0 -6
@@ -2,51 +2,47 @@
2
2
  * Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import { RealObjectMesh } from './real-object-mesh'
6
-
7
5
  import * as THREE from 'three'
6
+ import { applyAlpha } from './common'
8
7
 
9
- import { textTexture, textBounds } from './texture/text-texture'
8
+ import { RealObjectMesh } from './real-object-mesh'
9
+ import { textTexture } from './texture/text-texture'
10
10
 
11
11
  /**
12
12
  * RealObjectText
13
13
  */
14
14
  export class RealObjectText extends RealObjectMesh {
15
- buildGeometry() {
16
- // TODO component.text의 heavy한 로직을 반복적으로 실행하지 않도록, 캐싱하자.
17
- var {
18
- bold = false,
19
- italic = false,
20
- fontFamily = 'Serif',
21
- fontSize = 10,
22
- fontColor = 'black'
23
- } = this.component.state
15
+ buildGeometry() {}
24
16
 
25
- var text = this.component.text
26
- let { width, height } = textBounds(text, {
27
- bold,
28
- italic,
29
- fontFamily,
30
- fontSize,
31
- fontColor
32
- })
17
+ /* overide */
33
18
 
34
- // FIXME
35
- // ;(this.component as any).dimension = {
36
- // width,
37
- // height,
38
- // depth: 1
39
- // }
40
- this.component.setState({
41
- width,
42
- depth: 1,
43
- height
44
- })
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
45
31
 
46
- return new THREE.PlaneGeometry(width, height)
32
+ if (this.object3d.geometry) {
33
+ this.object3d.geometry.dispose()
34
+ }
35
+
36
+ /* scaling으로 해결되지 않기때문에, 새로 geometry를 만드는 방법을 사용한다 */
37
+ this.object3d.geometry = new THREE.PlaneGeometry(width, height)
47
38
  }
48
39
 
49
- buildMaterial() {
40
+ updateText() {
41
+ var material = this.object3d.material as THREE.MeshStandardMaterial
42
+ if (!material) {
43
+ return
44
+ }
45
+
50
46
  var {
51
47
  width,
52
48
  height,
@@ -54,44 +50,37 @@ export class RealObjectText extends RealObjectMesh {
54
50
  italic = false,
55
51
  fontFamily = 'Serif',
56
52
  fontSize = 10,
57
- fontColor = 'black'
53
+ fontColor = 'black',
54
+ fillStyle
58
55
  } = this.component.state
59
56
 
60
- // TODO component.text의 heavy한 로직을 반복적으로 실행하지 않도록, 캐싱하자.
61
57
  var text = this.component.text
62
58
 
63
- return new THREE.MeshBasicMaterial({
64
- map: textTexture(text, width, height, {
65
- bold,
66
- italic,
67
- fontFamily,
68
- fontSize,
69
- fontColor
70
- }),
71
- transparent: true,
72
- alphaTest: 0.2,
73
- side: THREE.DoubleSide
59
+ const texture = textTexture(text, width, height, {
60
+ bold,
61
+ italic,
62
+ fontFamily,
63
+ fontSize,
64
+ fontColor
74
65
  })
75
- }
76
66
 
77
- /* overide */
78
- updateDimension() {
79
- // Intentionally do nothing
80
- }
81
-
82
- get rotation() {
83
- const { rotationX = 0, rotationY = 0, rotation = 0 } = this.component.state
84
-
85
- return {
86
- x: rotationX - Math.PI / 2,
87
- y: rotationY,
88
- z: rotation
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
+ }
89
76
  }
90
77
  }
91
78
 
92
79
  updateAlpha() {
93
80
  // material의 transparency는 항상 true으로 유지되어야 한다.
94
- super.updateAlpha()
81
+ var { alpha = 1, fontColor } = this.component.state
82
+
83
+ applyAlpha(this.object3d.material, alpha, fontColor)
95
84
  ;(this.object3d.material as any).transparent = true
96
85
  }
97
86
  }
@@ -28,6 +28,7 @@ export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
28
28
  texture.minFilter = THREE.LinearFilter
29
29
  texture.encoding = THREE.sRGBEncoding
30
30
  texture.repeat.set(1, 1)
31
+ texture.needsUpdate = true
31
32
 
32
33
  component.invalidate()
33
34
  },
@@ -49,9 +50,13 @@ export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
49
50
  this.clear()
50
51
  this.build()
51
52
 
53
+ this.updateDimension()
52
54
  this.updateTransform()
55
+ this.updateFillStyle()
56
+ this.updateStrokeStyle()
53
57
  this.updateAlpha()
54
58
  this.updateHidden()
59
+ this.updateText()
55
60
  }
56
61
 
57
62
  protected getObject3dInstance(): T {
@@ -243,7 +248,8 @@ export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
243
248
  }
244
249
 
245
250
  updateDimension() {
246
- this.update()
251
+ var { width, height, depth } = this.dimension
252
+ this.object3d.scale.set(width, height, depth)
247
253
  }
248
254
 
249
255
  updateAlpha() {
@@ -270,32 +276,23 @@ export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
270
276
  this.object3d.visible = !this.component.state.hidden
271
277
  }
272
278
 
273
- updateStrokeStyle() {
274
- this.update()
275
- }
276
-
277
- updateFillStyle() {
278
- this.update()
279
- }
280
-
281
- updateText() {
282
- this.update()
283
- }
279
+ updateStrokeStyle() {}
280
+ updateFillStyle() {}
281
+ updateText() {}
284
282
 
285
283
  onchange(after: Properties, before: Properties) {
286
- if (hasProperties(this.rebuildingProperties, after)) {
287
- this.update()
288
- return
289
- }
290
-
291
284
  if (hasProperties(['cx', 'cy', 'cz', 'zPos', 'left', 'top'], after)) {
292
- this.updateDimension()
285
+ this.updatePosition()
293
286
  }
294
287
 
295
288
  if (hasProperties(['width', 'height', 'depth'], after)) {
296
289
  this.updateDimension()
297
290
  }
298
291
 
292
+ if (hasProperties(['rotationX', 'rotationY', 'rotation'], after)) {
293
+ this.updateRotate()
294
+ }
295
+
299
296
  if ('scale' in after) {
300
297
  this.updateScale()
301
298
  }
@@ -320,8 +317,4 @@ export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
320
317
  this.updateText()
321
318
  }
322
319
  }
323
-
324
- get rebuildingProperties(): string[] {
325
- return ['width', 'height', 'depth', 'fillStyle', 'strokeStyle', 'text', 'path']
326
- }
327
320
  }
@@ -21,7 +21,9 @@ export function createCanvasTexture(component: Component): THREE.Texture {
21
21
  texture.wrapT = THREE.RepeatWrapping
22
22
  texture.offset.set(0, 0)
23
23
  texture.repeat.set(1, 1)
24
- texture.minFilter = THREE.LinearFilter
24
+ texture.magFilter = THREE.NearestFilter
25
+ texture.minFilter = THREE.LinearMipMapLinearFilter
26
+ texture.encoding = THREE.sRGBEncoding
25
27
 
26
28
  return texture
27
29
  }
package/src/wall.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
- import { Component, RectPath, Shape } from '@hatiolab/things-scene'
4
+ import { Component, Properties, RectPath, Shape } from '@hatiolab/things-scene'
5
5
  import * as THREE from 'three'
6
6
  import { RealObject } from './threed/real-object'
7
7
  import { RealObjectMesh } from './threed/real-object-mesh'
@@ -23,14 +23,13 @@ const NATURE = {
23
23
 
24
24
  export class Wall3D extends RealObjectMesh {
25
25
  buildGeometry() {
26
- var { width, height, depth = 1 } = this.component.state
27
- return new THREE.BoxGeometry(width, depth, height)
26
+ this.object3d.geometry = new THREE.BoxGeometry(1, 1, 1)
28
27
  }
29
28
 
30
- buildMaterial() {
31
- var { fillStyle = 'gray' } = this.component.state
29
+ updateDimension(): void {
30
+ var { width, height, depth = 1 } = this.component.state
32
31
 
33
- return new THREE.MeshStandardMaterial({ color: fillStyle, side: THREE.FrontSide })
32
+ this.object3d.scale.set(width, depth, height)
34
33
  }
35
34
  }
36
35