@things-factory/scene-visualizer 6.0.1 → 6.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@things-factory/scene-visualizer",
3
3
  "description": "The visualizer component for things-scene.",
4
- "version": "6.0.1",
4
+ "version": "6.0.3",
5
5
  "things-scene": true,
6
6
  "browser": "src/index.js",
7
7
  "author": "heartyoh <heartyoh@hatiolab.com>",
@@ -19,5 +19,5 @@
19
19
  "lit": "^2.5.0",
20
20
  "three": "^0.122.0"
21
21
  },
22
- "gitHead": "e5fe832cd3b1ac14b80d5bc9be2a2e650ab31d51"
22
+ "gitHead": "6d9a3aef103e6d8293bfce285662d15ec9c0d705"
23
23
  }
package/src/index.js CHANGED
@@ -1,25 +1,21 @@
1
1
  /*
2
2
  * Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
+ export { default } from './object-3d-overload'
5
+
4
6
  export { default as Banner } from './banner'
5
7
  export { default as Component3d } from './component-3d'
6
- export { default as Cone } from './cone'
7
8
  export { default as Cube } from './cube'
8
9
  export { default as Cylinder } from './cylinder'
9
10
  export { default as Desk } from './desk'
10
- // export { default as Door } from './door'
11
11
  export { default as EllipseExtrude } from './ellipse-extrude'
12
12
  export { default as GLTFObject } from './gltf-object'
13
- // export { default as HumiditySensor } from './humidity-sensor'
14
- export { default } from './object-3d-overload'
15
13
  export { default as PolygonExtrude } from './polygon-extrude'
16
14
  export { default as Rack } from './rack'
17
15
  export { default as RackTable } from './rack-table'
18
16
  export { default as RackTableCell } from './rack-table-cell'
19
17
  export { default as RectExtrude } from './rect-extrude'
20
18
  export { default as Sphere } from './sphere'
21
- // export { default as Stock } from './stock'
22
19
  export { default as TextTextureObject } from './text-texture-object'
23
- // export { default as VideoPlayer360 } from './video-player-360'
24
20
  export { default as Visualizer } from './visualizer'
25
21
  export { default as Wall } from './wall'
package/src/mesh.js CHANGED
@@ -8,6 +8,7 @@ export default class Mesh extends THREE.Mesh {
8
8
  super()
9
9
 
10
10
  this._model = model
11
+ this.type = model.type
11
12
 
12
13
  this._visualizer = visualizer
13
14
  this._canvasSize = canvasSize
@@ -25,13 +26,6 @@ export default class Mesh extends THREE.Mesh {
25
26
  return this._model
26
27
  }
27
28
 
28
- get type() {
29
- return this.model.type || this._type
30
- }
31
- set type(type) {
32
- this._type = type
33
- }
34
-
35
29
  get cx() {
36
30
  if (!this._cx) {
37
31
  var { left = 0, width = 0 } = this.model
package/src/object3d.js CHANGED
@@ -7,6 +7,7 @@ export default class Object3D extends THREE.Object3D {
7
7
  super()
8
8
 
9
9
  this._model = model
10
+ this.type = model.type
10
11
 
11
12
  this._visualizer = visualizer
12
13
  this._canvasSize = canvasSize
@@ -36,13 +37,6 @@ export default class Object3D extends THREE.Object3D {
36
37
  return this._model
37
38
  }
38
39
 
39
- get type() {
40
- return this.model.type || this._type
41
- }
42
- set type(type) {
43
- this._type = type
44
- }
45
-
46
40
  get cx() {
47
41
  if (!this._cx) {
48
42
  var { left = 0, width = 0 } = this.model
@@ -182,9 +182,9 @@ export default class RackTableCell extends RectPath(Component) {
182
182
  context.restore()
183
183
  }
184
184
 
185
- get tag() {
185
+ get decotag() {
186
186
  var rackTable = this.parent
187
- var { locPattern, zone } = rackTable.model
187
+ var { locPattern, zone = '' } = rackTable.model
188
188
 
189
189
  locPattern = locPattern.substring(0, locPattern.indexOf('{u}') + 3)
190
190
 
@@ -348,11 +348,11 @@ export default class RackTableCell extends RectPath(Component) {
348
348
  }
349
349
 
350
350
  onmouseenter() {
351
- this.trigger('tag', this)
351
+ this.trigger('tag')
352
352
  }
353
353
 
354
354
  onmouseleave() {
355
- this.trigger('tagreset', this)
355
+ this.trigger('tagreset')
356
356
  }
357
357
 
358
358
  contains(x, y) {
package/src/visualizer.js CHANGED
@@ -2,10 +2,10 @@
2
2
  * Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
  // import OBJExporter from 'three-obj-exporter'
5
- import { Component, ContainerAbstract, error, FPS, Layer, Layout, ScriptLoader } from '@hatiolab/things-scene'
5
+ import { Component, ContainerAbstract, ScenePopup, FPS, Layout } from '@hatiolab/things-scene'
6
6
  import * as THREE from 'three'
7
+ import { TGALoader } from 'three/examples/jsm/loaders/TGALoader.js'
7
8
  import Component3d from './component-3d'
8
- import TGALoader from './loaders/TGALoader'
9
9
  import ThreeControls from './three-controls'
10
10
  import './three-layout'
11
11
 
@@ -247,29 +247,6 @@ export default class Visualizer extends ContainerAbstract {
247
247
  return this._objects[id]
248
248
  }
249
249
 
250
- added() {
251
- if (!this.app.isViewMode) return
252
-
253
- var loadLoaders = () => {
254
- if (!THREE) return
255
-
256
- // ScriptLoader.load(OBJLoader);
257
- // ScriptLoader.load(MTLLoader);
258
- // ScriptLoader.load(TGALoader);
259
- }
260
-
261
- if (!THREE) {
262
- ScriptLoader.load(three).then(() => {
263
- THREE.Cache.enabled = true
264
- // require('./object-3d-overload');
265
- // ScriptLoader.load
266
- // loadLoaders();
267
- }, error)
268
- }
269
- // else
270
- // loadLoaders();
271
- }
272
-
273
250
  /* THREE Object related .. */
274
251
 
275
252
  createFloor(color, width, height) {
@@ -411,26 +388,6 @@ export default class Visualizer extends ContainerAbstract {
411
388
  if (this._scene3d) this.destroy_scene3d()
412
389
 
413
390
  this._initalizeComplete = new Promise(async resolve => {
414
- // var self = this;
415
-
416
- // THREE.DefaultLoadingManager.onStart = function (item, loaded, total) {
417
- // createProgressbar(self.root.target_element);
418
- // self._loadComplete = false;
419
- // }
420
-
421
- // THREE.DefaultLoadingManager.onProgress = function (item, loaded, total) {
422
- // var a = this;
423
- // showProgressbar(self.root.target_element, loaded, total)
424
- // }
425
- // THREE.DefaultLoadingManager.onLoad = function (item, loaded, total) {
426
- // removeProgressBar(self.root.target_element)
427
- // self._loadComplete = true;
428
- // }
429
-
430
- // THREE.DefaultLoadingManager.onError = function (url) {
431
- // console.warn('There was an error loading ' + url);
432
- // }
433
-
434
391
  registerLoaders()
435
392
  this._textureLoader = new THREE.TextureLoader(THREE.DefaultLoadingManager)
436
393
  this._textureLoader.withCredential = true
@@ -862,8 +819,6 @@ export default class Visualizer extends ContainerAbstract {
862
819
  if (this._controls) {
863
820
  if (this._lastFocused) this._lastFocused._focused = false
864
821
 
865
- var modelLayer = Layer.register('model-layer')
866
- var popup = modelLayer.Popup
867
822
  var ref = this.model.popupScene
868
823
  var pointer = this.transcoordC2S(e.offsetX, e.offsetY)
869
824
 
@@ -875,7 +830,7 @@ export default class Visualizer extends ContainerAbstract {
875
830
  if (object && object.onmouseup) {
876
831
  if (ref)
877
832
  object.onmouseup(e, this, data => {
878
- popup.show(this, ref, {
833
+ ScenePopup.show(this, ref, {
879
834
  ...data,
880
835
  location: this.state.popupPosition || 'right-top'
881
836
  })
@@ -885,7 +840,7 @@ export default class Visualizer extends ContainerAbstract {
885
840
  object._focusedAt = performance.now()
886
841
  this._lastFocused = object
887
842
  } else {
888
- popup.hide(this.root)
843
+ ScenePopup.hide(this.root)
889
844
  }
890
845
 
891
846
  this.invalidate()
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/assets/pallet.png DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
package/assets/worker.png DELETED
Binary file
package/src/cone.js DELETED
@@ -1,88 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import { Component, Ellipse } from '@hatiolab/things-scene'
5
- import * as THREE from 'three'
6
- import Component3d from './component-3d'
7
-
8
- const NATURE = {
9
- mutable: false,
10
- resizable: true,
11
- rotatable: true,
12
- properties: [
13
- {
14
- type: 'number',
15
- label: 'depth',
16
- name: 'rz',
17
- property: 'rz'
18
- }
19
- ],
20
- help: 'scene/component/cone'
21
- }
22
-
23
- export default class Cone extends THREE.Mesh {
24
- constructor(model, canvasSize) {
25
- super()
26
-
27
- this._model = model
28
-
29
- this.createObject(model, canvasSize)
30
- }
31
-
32
- async createObject(model, canvasSize) {
33
- let cx = model.cx - canvasSize.width / 2
34
- let cy = model.cy - canvasSize.height / 2
35
- let cz = this.model.rx
36
-
37
- let rotation = model.rotation
38
- this.type = model.type
39
-
40
- this.createCone(this.model.rx, this.model.rz)
41
-
42
- this.position.set(cx, cz, cy) // z좌표는 땅에 붙어있게 함
43
- this.rotation.y = rotation || 0
44
- }
45
-
46
- createCone(rx, rz) {
47
- let { fillStyle = 'lightgray' } = this.model
48
-
49
- this.geometry = new THREE.ConeBufferGeometry(rx, rz, 20)
50
- this.material = new THREE.MeshStandardMaterial({
51
- color: fillStyle,
52
- side: THREE.FrontSide
53
- })
54
-
55
- // this.castShadow = true
56
- }
57
-
58
- setEuler(euler) {
59
- var { yaw, pitch, roll } = euler
60
-
61
- this.setRotationFromEuler(new THREE.Vector3(roll, pitch, yaw))
62
- }
63
-
64
- setQuaternion(quaternion) {
65
- var { x, y, z, w } = quaternion
66
-
67
- this.setRotationFromQuaternion(new THREE.Quaternion(x, y, z, w))
68
- }
69
-
70
- get model() {
71
- return this._model
72
- }
73
- }
74
-
75
- export class Cone2d extends Ellipse {
76
- is3dish() {
77
- return true
78
- }
79
-
80
- get controls() {}
81
-
82
- get nature() {
83
- return NATURE
84
- }
85
- }
86
-
87
- Component.register('cone', Cone2d)
88
- Component3d.register('cone', Cone)
package/src/door.js DELETED
@@ -1,52 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import { Component, Rect } from '@hatiolab/things-scene'
5
- import * as THREE from 'three'
6
- import Component3d from './component-3d'
7
-
8
- export default class Door extends THREE.Mesh {
9
- constructor(model, canvasSize) {
10
- super()
11
-
12
- this._model = model
13
-
14
- this.createObject(model, canvasSize)
15
- }
16
-
17
- async createObject(model, canvasSize) {
18
- let cx = model.left + model.width / 2 - canvasSize.width / 2
19
- let cy = model.top + model.height / 2 - canvasSize.height / 2
20
- let cz = 0.5 * model.depth
21
-
22
- let rotation = model.rotation
23
- this.type = model.type
24
-
25
- this.createDoor(model.width, model.height, model.depth)
26
-
27
- this.position.set(cx, cz, cy)
28
- this.rotation.y = rotation || 0
29
- }
30
-
31
- createDoor(w, h, d) {
32
- let { fillStyle = 'saddlebrown' } = this.model
33
-
34
- this.geometry = new THREE.BoxBufferGeometry(w, d, h)
35
- this.material = new THREE.MeshStandardMaterial({ color: fillStyle, side: THREE.FrontSide })
36
-
37
- // this.castShadow = true
38
- }
39
-
40
- get model() {
41
- return this._model
42
- }
43
- }
44
-
45
- export class Door2d extends Rect {
46
- is3dish() {
47
- return true
48
- }
49
- }
50
-
51
- Component.register('door', Door2d)
52
- Component3d.register('door', Door)
package/src/floor.js DELETED
@@ -1,162 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import Cube from './cube'
5
-
6
- export default class Floor extends Cube {
7
- createColors() {
8
- var colorsOfFaces = [
9
- [1.0, 0.3, 0.3, 1.0], // Front face: cyan
10
- [1.0, 0.3, 0.3, 1.0], // Back face: red
11
- [1.0, 0.3, 0.3, 1.0], // Top face: green
12
- [1.0, 0.3, 0.3, 1.0], // Bottom face: blue
13
- [1.0, 0.3, 0.3, 1.0], // Right face: yellow
14
- [1.0, 0.3, 0.3, 1.0] // Left face: purple
15
- ]
16
-
17
- var colors = []
18
-
19
- for (var j = 0; j < 6; j++) {
20
- var polygonColor = colorsOfFaces[j]
21
-
22
- for (var i = 0; i < 4; i++) {
23
- colors = colors.concat(polygonColor)
24
- }
25
- }
26
-
27
- return colors
28
- }
29
-
30
- createPositions() {
31
- var positions = [
32
- // Front face
33
- -1.0,
34
- -1.0,
35
- 1.0,
36
- 1.0,
37
- -1.0,
38
- 1.0,
39
- 1.0,
40
- 1.0,
41
- 1.0,
42
- -1.0,
43
- 1.0,
44
- 1.0,
45
-
46
- // Back face
47
- -1.0,
48
- -1.0,
49
- -1.0,
50
- -1.0,
51
- 1.0,
52
- -1.0,
53
- 1.0,
54
- 1.0,
55
- -1.0,
56
- 1.0,
57
- -1.0,
58
- -1.0,
59
-
60
- // Top face
61
- -1.0,
62
- 1.0,
63
- -1.0,
64
- -1.0,
65
- 1.0,
66
- 1.0,
67
- 1.0,
68
- 1.0,
69
- 1.0,
70
- 1.0,
71
- 1.0,
72
- -1.0,
73
-
74
- // Bottom face
75
- -1.0,
76
- -1.0,
77
- -1.0,
78
- 1.0,
79
- -1.0,
80
- -1.0,
81
- 1.0,
82
- -1.0,
83
- 1.0,
84
- -1.0,
85
- -1.0,
86
- 1.0,
87
-
88
- // Right face
89
- 1.0,
90
- -1.0,
91
- -1.0,
92
- 1.0,
93
- 1.0,
94
- -1.0,
95
- 1.0,
96
- 1.0,
97
- 1.0,
98
- 1.0,
99
- -1.0,
100
- 1.0,
101
-
102
- // Left face
103
- -1.0,
104
- -1.0,
105
- -1.0,
106
- -1.0,
107
- -1.0,
108
- 1.0,
109
- -1.0,
110
- 1.0,
111
- 1.0,
112
- -1.0,
113
- 1.0,
114
- -1.0
115
- ]
116
-
117
- return positions
118
- }
119
-
120
- createElements() {
121
- var elements = [
122
- 0,
123
- 1,
124
- 2,
125
- 0,
126
- 2,
127
- 3, // front
128
- 4,
129
- 5,
130
- 6,
131
- 4,
132
- 6,
133
- 7, // back
134
- 8,
135
- 9,
136
- 10,
137
- 8,
138
- 10,
139
- 11, // top
140
- 12,
141
- 13,
142
- 14,
143
- 12,
144
- 14,
145
- 15, // bottom
146
- 16,
147
- 17,
148
- 18,
149
- 16,
150
- 18,
151
- 19, // right
152
- 20,
153
- 21,
154
- 22,
155
- 20,
156
- 22,
157
- 23 // left
158
- ]
159
-
160
- return elements
161
- }
162
- }