@operato/scene-visualizer 8.0.0-beta.1 → 8.0.0
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 +6 -6
- package/CHANGELOG.md +0 -649
- 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
package/src/rack.ts
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
|
7
|
-
|
|
8
|
-
import { Stock } from './stock'
|
|
9
|
-
import { Material } from 'three'
|
|
10
|
-
import { RackTable } from './rack-table'
|
|
11
|
-
import { RealObject } from './threed/real-object'
|
|
12
|
-
import { Visualizer } from './visualizer'
|
|
13
|
-
|
|
14
|
-
export class Rack extends RealObject {
|
|
15
|
-
private _frame?: THREE.BufferGeometry
|
|
16
|
-
private _board?: THREE.BufferGeometry
|
|
17
|
-
|
|
18
|
-
static frameMaterial: Material = new THREE.MeshStandardMaterial({
|
|
19
|
-
color: 0xcccccc,
|
|
20
|
-
roughness: 0.5,
|
|
21
|
-
metalness: 0.3
|
|
22
|
-
})
|
|
23
|
-
static rackFrameGeometry = new THREE.BoxGeometry(1, 1, 1)
|
|
24
|
-
static boardGeometry = new THREE.PlaneGeometry(1, 1, 1, 1)
|
|
25
|
-
|
|
26
|
-
private static _boardMaterial?: THREE.MeshStandardMaterial
|
|
27
|
-
|
|
28
|
-
get visualizer(): Visualizer | undefined {
|
|
29
|
-
var component = this.component
|
|
30
|
-
|
|
31
|
-
while (component) {
|
|
32
|
-
if (component.state.type == 'visualizer') {
|
|
33
|
-
return component as Visualizer
|
|
34
|
-
}
|
|
35
|
-
component = component.parent
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get rackTable(): RackTable | undefined {
|
|
40
|
-
var component = this.component
|
|
41
|
-
|
|
42
|
-
while (component) {
|
|
43
|
-
if (component.state.type == 'rack-table') {
|
|
44
|
-
return component as RackTable
|
|
45
|
-
}
|
|
46
|
-
component = component.parent
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get cz() {
|
|
51
|
-
var { shelves = 1, depth = 1 } = this.rackTable!.state
|
|
52
|
-
|
|
53
|
-
return 0.5 * depth * shelves
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static get boardMaterial() {
|
|
57
|
-
if (!Rack._boardMaterial) {
|
|
58
|
-
Rack._boardMaterial = new THREE.MeshStandardMaterial({
|
|
59
|
-
color: '#dedede',
|
|
60
|
-
side: THREE.DoubleSide,
|
|
61
|
-
polygonOffset: true,
|
|
62
|
-
polygonOffsetFactor: -0.1
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return Rack._boardMaterial
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get frame() {
|
|
70
|
-
return this._frame
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get board() {
|
|
74
|
-
return this._board
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
build() {
|
|
78
|
-
super.build()
|
|
79
|
-
|
|
80
|
-
var { depth, hideRackFrame, shelves, shelfLocations: commonShelfLocation, stockScale = 0.7 } = this.rackTable!.state
|
|
81
|
-
|
|
82
|
-
var { width, height, shelfLocations = commonShelfLocation, binLocations = '' } = this.component.state
|
|
83
|
-
|
|
84
|
-
let scale = stockScale
|
|
85
|
-
|
|
86
|
-
var shelfLocIds
|
|
87
|
-
|
|
88
|
-
if (!shelfLocations) {
|
|
89
|
-
shelfLocIds = []
|
|
90
|
-
for (var i = 0; i < shelves; i++) shelfLocIds.push(i + 1)
|
|
91
|
-
} else shelfLocIds = shelfLocations.split(/\s*,\s*/)
|
|
92
|
-
|
|
93
|
-
var shelfBins = binLocations.trim().split('\n').reverse()
|
|
94
|
-
|
|
95
|
-
if (!hideRackFrame) {
|
|
96
|
-
this._frame = this.createRackFrame(width, height, depth * shelves)
|
|
97
|
-
this._board = this.createRackBoards(shelves, width, height, depth, shelfLocIds)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
for (var i = 0; i < shelves; i++) {
|
|
101
|
-
let bottom = -depth * shelves * 0.5
|
|
102
|
-
if (shelfLocIds[i] == '') {
|
|
103
|
-
continue
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
var bins = (shelfBins[i] || '').trim().split(/\s*,\s*/)
|
|
107
|
-
|
|
108
|
-
var binWidth = width / (bins.length || 1)
|
|
109
|
-
for (var b = 0; b < bins.length; b++) {
|
|
110
|
-
let stock = new Stock(this.component, {
|
|
111
|
-
width: binWidth * scale,
|
|
112
|
-
height: height * scale,
|
|
113
|
-
depth: depth * scale
|
|
114
|
-
})
|
|
115
|
-
stock.update()
|
|
116
|
-
|
|
117
|
-
let stockDepth = depth * scale
|
|
118
|
-
|
|
119
|
-
stock.object3d.position.set(
|
|
120
|
-
(width / 2) * ((2 * b - (bins.length - 1)) / bins.length),
|
|
121
|
-
bottom + depth * i + stockDepth * 0.5,
|
|
122
|
-
0
|
|
123
|
-
)
|
|
124
|
-
var binCode = (bins[b] || '').replace('.', '')
|
|
125
|
-
stock.object3d.name = `${this.makeLocationString(shelfLocIds[i])}${binCode}`
|
|
126
|
-
|
|
127
|
-
this.object3d.add(stock.object3d)
|
|
128
|
-
this.visualizer!.putObject(stock.object3d.name, stock)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
createRackFrame(w: number, h: number, d: number): THREE.BufferGeometry {
|
|
134
|
-
const frameWeight = Math.round(Math.min(w, h) / 10)
|
|
135
|
-
const geometries = []
|
|
136
|
-
|
|
137
|
-
for (let i = 0; i < 4; i++) {
|
|
138
|
-
const geometry = Rack.rackFrameGeometry.clone()
|
|
139
|
-
geometry.scale(frameWeight, d, frameWeight)
|
|
140
|
-
|
|
141
|
-
switch (i) {
|
|
142
|
-
case 0:
|
|
143
|
-
geometry.translate(w / 2, 0, h / 2)
|
|
144
|
-
break
|
|
145
|
-
case 1:
|
|
146
|
-
geometry.translate(w / 2, 0, -h / 2)
|
|
147
|
-
break
|
|
148
|
-
case 2:
|
|
149
|
-
geometry.translate(-w / 2, 0, h / 2)
|
|
150
|
-
break
|
|
151
|
-
case 3:
|
|
152
|
-
geometry.translate(-w / 2, 0, -h / 2)
|
|
153
|
-
break
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
geometries.push(geometry)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return BufferGeometryUtils.mergeGeometries(geometries)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
createRackBoards(
|
|
163
|
-
shelves: number,
|
|
164
|
-
width: number,
|
|
165
|
-
height: number,
|
|
166
|
-
depth: number,
|
|
167
|
-
shelfLocIds: string[]
|
|
168
|
-
): THREE.BufferGeometry {
|
|
169
|
-
let bottom = -depth * shelves * 0.5
|
|
170
|
-
const geometries = []
|
|
171
|
-
|
|
172
|
-
for (let i = 1; i < shelves; i++) {
|
|
173
|
-
if (shelfLocIds[i] === '') {
|
|
174
|
-
continue
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const geometry = Rack.boardGeometry.clone()
|
|
178
|
-
|
|
179
|
-
geometry.scale(width, height, 1)
|
|
180
|
-
geometry.rotateX(Math.PI / 2)
|
|
181
|
-
geometry.translate(0, bottom + depth * i, 0)
|
|
182
|
-
|
|
183
|
-
geometries.push(geometry)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return BufferGeometryUtils.mergeGeometries(geometries)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
makeLocationString(shelfString: string) {
|
|
190
|
-
var { section = '', unit = '' } = this.component.state
|
|
191
|
-
var { locPattern = '{z}{s}-{u}-{sh}', zone = '' } = this.rackTable!.state
|
|
192
|
-
|
|
193
|
-
var locationString = locPattern
|
|
194
|
-
|
|
195
|
-
locationString = locationString.replace(/{z}/i, zone)
|
|
196
|
-
locationString = locationString.replace(/{s}/i, section)
|
|
197
|
-
locationString = locationString.replace(/{u}/i, unit)
|
|
198
|
-
locationString = locationString.replace(/{sh}/i, shelfString)
|
|
199
|
-
|
|
200
|
-
return locationString
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
makeShelfString(pattern: string, shelf: number, length: number) {
|
|
204
|
-
/**
|
|
205
|
-
* pattern #: 숫자
|
|
206
|
-
* pattern 0: 고정 자리수
|
|
207
|
-
* pattern -: 역순
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
if (!pattern || !shelf || !length) return
|
|
211
|
-
|
|
212
|
-
var isReverse = /^\-/.test(pattern)
|
|
213
|
-
pattern = pattern.replace(/#+/, '#')
|
|
214
|
-
|
|
215
|
-
var fixedLength = (pattern.match(/0/g) || []).length || 0
|
|
216
|
-
var shelfString = String(isReverse ? length - shelf + 1 : shelf)
|
|
217
|
-
|
|
218
|
-
if (shelfString.length > fixedLength && fixedLength > 0) {
|
|
219
|
-
shelfString = shelfString.substring(shelfString.length - fixedLength)
|
|
220
|
-
} else {
|
|
221
|
-
var prefix = ''
|
|
222
|
-
for (var i = 0; i < fixedLength - shelfString.length; i++) {
|
|
223
|
-
prefix += '0'
|
|
224
|
-
}
|
|
225
|
-
shelfString = prefix + shelfString
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return shelfString
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
updateAlpha() {}
|
|
232
|
-
}
|
package/src/rect.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { Rect } from '@hatiolab/things-scene'
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import { RealObjectExtrude } from './threed/real-object-extrude'
|
|
7
|
-
|
|
8
|
-
export class RectExtrude extends RealObjectExtrude {
|
|
9
|
-
get shape() {
|
|
10
|
-
var { width, height, round } = this.component.state
|
|
11
|
-
var shape = new THREE.Shape()
|
|
12
|
-
|
|
13
|
-
if (round > 0) {
|
|
14
|
-
var radius = (round / 100) * (width / 2)
|
|
15
|
-
|
|
16
|
-
shape.moveTo(radius, 0)
|
|
17
|
-
shape.lineTo(width - radius, 0)
|
|
18
|
-
shape.quadraticCurveTo(width, 0, width, radius)
|
|
19
|
-
shape.lineTo(width, height - radius)
|
|
20
|
-
shape.quadraticCurveTo(width, height, width - radius, height)
|
|
21
|
-
shape.lineTo(radius, height)
|
|
22
|
-
shape.quadraticCurveTo(0, height, 0, height - radius)
|
|
23
|
-
shape.lineTo(0, radius)
|
|
24
|
-
shape.quadraticCurveTo(0, 0, radius, 0)
|
|
25
|
-
} else {
|
|
26
|
-
shape.moveTo(0, 0)
|
|
27
|
-
shape.lineTo(width, 0)
|
|
28
|
-
shape.lineTo(width, height)
|
|
29
|
-
shape.lineTo(0, height)
|
|
30
|
-
shape.lineTo(0, 0)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return shape
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
Rect.prototype.buildRealObject = function () {
|
|
38
|
-
return new RectExtrude(this)
|
|
39
|
-
}
|
package/src/scene/component.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Component } from '@hatiolab/things-scene'
|
|
2
|
-
import { RealObject } from '../threed/real-object'
|
|
3
|
-
import { RealObjectSprite2D } from '../threed/real-object-sprite-2d'
|
|
4
|
-
|
|
5
|
-
Component.prototype.buildRealObject = function (this: Component): RealObject | undefined {
|
|
6
|
-
return new RealObjectSprite2D(this)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
Component.prototype.is3dish = function (this: Component): boolean {
|
|
10
|
-
return true
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(Component.prototype, 'realObject', {
|
|
14
|
-
get: function (this: Component): RealObject | undefined {
|
|
15
|
-
if (!this.disposed && !this._realObject) {
|
|
16
|
-
this._realObject = this.buildRealObject()
|
|
17
|
-
|
|
18
|
-
if (!this._realObject) {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
this._realObject.update()
|
|
23
|
-
this._realObject.updateTransform()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return this._realObject
|
|
27
|
-
},
|
|
28
|
-
enumerable: false,
|
|
29
|
-
configurable: false
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
var oldDispose = Component.prototype.dispose
|
|
33
|
-
|
|
34
|
-
Component.prototype.dispose = function () {
|
|
35
|
-
oldDispose.call(this)
|
|
36
|
-
|
|
37
|
-
this.realObject && (this.realObject as any).dispose()
|
|
38
|
-
}
|
package/src/sphere.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { Component, ComponentNature, Ellipse } from '@hatiolab/things-scene'
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
import { RealObject } from './threed/real-object'
|
|
7
|
-
import { RealObjectMesh } from './threed/real-object-mesh'
|
|
8
|
-
|
|
9
|
-
const NATURE: ComponentNature = {
|
|
10
|
-
mutable: false,
|
|
11
|
-
resizable: true,
|
|
12
|
-
rotatable: true,
|
|
13
|
-
properties: [],
|
|
14
|
-
help: 'scene/component/sphere'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Sphere3D extends RealObjectMesh {
|
|
18
|
-
buildGeometry() {
|
|
19
|
-
var { rx = 0 } = this.component.state
|
|
20
|
-
|
|
21
|
-
this.object3d.geometry = new THREE.SphereGeometry(rx, 20, 20)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class Sphere extends Ellipse {
|
|
26
|
-
is3dish() {
|
|
27
|
-
return true
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
buildRealObject(): RealObject | undefined {
|
|
31
|
-
return new Sphere3D(this)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get nature() {
|
|
35
|
-
return NATURE
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
Component.register('sphere', Sphere)
|
package/src/sprite.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'
|
|
6
|
-
import { RealObject } from './threed/real-object'
|
|
7
|
-
import { RealObjectSprite2D } from './threed/real-object-sprite-2d'
|
|
8
|
-
|
|
9
|
-
const NATURE: ComponentNature = {
|
|
10
|
-
mutable: false,
|
|
11
|
-
resizable: true,
|
|
12
|
-
rotatable: true,
|
|
13
|
-
properties: []
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class Sprite extends RectPath(Shape) {
|
|
17
|
-
is3dish(): boolean {
|
|
18
|
-
return true
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
buildRealObject(): RealObject | undefined {
|
|
22
|
-
return new RealObjectSprite2D(this)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get nature() {
|
|
26
|
-
return NATURE
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
Component.register('sprite', Sprite)
|
package/src/stock.ts
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Component, Model } from '@hatiolab/things-scene'
|
|
6
|
-
import * as THREE from 'three'
|
|
7
|
-
import { RealObject } from './threed/real-object'
|
|
8
|
-
import { Visualizer } from './visualizer'
|
|
9
|
-
|
|
10
|
-
const STOCK_COLOR = '#ccaa76'
|
|
11
|
-
|
|
12
|
-
export class Stock extends RealObject<THREE.Mesh> {
|
|
13
|
-
static defaultMaterial = new THREE.MeshStandardMaterial({
|
|
14
|
-
color: STOCK_COLOR,
|
|
15
|
-
side: THREE.FrontSide,
|
|
16
|
-
roughness: 0.7
|
|
17
|
-
})
|
|
18
|
-
static stockGeometry = new THREE.BoxGeometry(1, 1, 1)
|
|
19
|
-
|
|
20
|
-
_hideEmptyStock: boolean = false
|
|
21
|
-
_focused: boolean = false
|
|
22
|
-
_focusedAt?: number
|
|
23
|
-
|
|
24
|
-
model: Model
|
|
25
|
-
|
|
26
|
-
constructor(component: Component, model: Model) {
|
|
27
|
-
super(component)
|
|
28
|
-
this.model = model
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected getObject3dInstance() {
|
|
32
|
-
return new THREE.Mesh()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getMaterial(index: number) {
|
|
36
|
-
var visualizer = this.visualizer
|
|
37
|
-
|
|
38
|
-
if (!(visualizer && visualizer && visualizer!.legendTarget && visualizer!.legendTarget.getState('status')))
|
|
39
|
-
return this.userDefineDefaultMaterial
|
|
40
|
-
|
|
41
|
-
var stockStatus = visualizer.legendTarget.getState('status')
|
|
42
|
-
var range = stockStatus.ranges[index]
|
|
43
|
-
if (!(range && range.color)) {
|
|
44
|
-
this.stockMaterials[index] = this.userDefineDefaultMaterial
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!this.stockMaterials[index]) {
|
|
48
|
-
this.stockMaterials[index] = new THREE.MeshStandardMaterial({
|
|
49
|
-
color: range.color,
|
|
50
|
-
side: THREE.FrontSide,
|
|
51
|
-
roughness: 0.7
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var alpha = range.color.replace(/^.*,(.+)\)/, '$1')
|
|
56
|
-
if (alpha > 0 && alpha < 1) {
|
|
57
|
-
this.stockMaterials[index].opacity = alpha
|
|
58
|
-
this.stockMaterials[index].transparent = true
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return this.stockMaterials[index]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
get visualizer(): Visualizer | undefined {
|
|
65
|
-
var component = this.component
|
|
66
|
-
|
|
67
|
-
while (component) {
|
|
68
|
-
if (component.state.type == 'visualizer') {
|
|
69
|
-
return component as Visualizer
|
|
70
|
-
}
|
|
71
|
-
component = component.parent
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get stockMaterials() {
|
|
76
|
-
return this.visualizer!._stock_materials
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get userDefineDefaultMaterial() {
|
|
80
|
-
var visualizer = this.visualizer
|
|
81
|
-
|
|
82
|
-
if (!visualizer!._default_material) {
|
|
83
|
-
if (!(visualizer && visualizer && visualizer!.legendTarget && visualizer!.legendTarget.getState('status')))
|
|
84
|
-
return Stock.defaultMaterial
|
|
85
|
-
|
|
86
|
-
var stockStatus = visualizer!.legendTarget.getState('status')
|
|
87
|
-
var defaultColor = stockStatus.defaultColor
|
|
88
|
-
|
|
89
|
-
if (!defaultColor) return Stock.defaultMaterial
|
|
90
|
-
|
|
91
|
-
visualizer!._default_material = new THREE.MeshStandardMaterial({
|
|
92
|
-
color: defaultColor,
|
|
93
|
-
side: THREE.FrontSide,
|
|
94
|
-
roughness: 0.7
|
|
95
|
-
})
|
|
96
|
-
var alpha = defaultColor.replace(/^.*,(.+)\)/, '$1')
|
|
97
|
-
if (alpha > 0 && alpha < 1) {
|
|
98
|
-
visualizer!._default_material.opacity = alpha
|
|
99
|
-
visualizer!._default_material.transparent = true
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return visualizer!._default_material
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get emptyMaterial() {
|
|
106
|
-
var visualizer = this.visualizer
|
|
107
|
-
|
|
108
|
-
var defaultColor = STOCK_COLOR
|
|
109
|
-
if (!visualizer!._empty_material) {
|
|
110
|
-
if (visualizer && visualizer && visualizer!.legendTarget && visualizer!.legendTarget.getState('status')) {
|
|
111
|
-
var stockStatus = visualizer!.legendTarget.getState('status')
|
|
112
|
-
defaultColor = stockStatus.defaultColor || STOCK_COLOR
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
visualizer!._empty_material = new THREE.MeshStandardMaterial({
|
|
116
|
-
color: defaultColor
|
|
117
|
-
})
|
|
118
|
-
var alpha = Number(defaultColor.replace(/^.*,(.+)\)/, '$1'))
|
|
119
|
-
if (alpha > 0 && alpha < 1) {
|
|
120
|
-
visualizer!._empty_material.opacity = alpha
|
|
121
|
-
visualizer!._empty_material.transparent = true
|
|
122
|
-
} else {
|
|
123
|
-
visualizer!._empty_material.opacity = 0.33
|
|
124
|
-
visualizer!._empty_material.transparent = true
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return visualizer!._empty_material
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
build() {
|
|
132
|
-
super.build()
|
|
133
|
-
|
|
134
|
-
var visualizer = this.visualizer
|
|
135
|
-
var { width, height, depth } = this.model
|
|
136
|
-
|
|
137
|
-
this._hideEmptyStock = visualizer && visualizer!.model.hideEmptyStock
|
|
138
|
-
|
|
139
|
-
this.createStock(width, height, depth)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
createStock(w: number, h: number, d: number) {
|
|
143
|
-
this.object3d.geometry = Stock.stockGeometry
|
|
144
|
-
this.object3d.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
145
|
-
|
|
146
|
-
this.object3d.scale.set(w, d, h)
|
|
147
|
-
|
|
148
|
-
this.object3d.receiveShadow = true
|
|
149
|
-
|
|
150
|
-
this.object3d.castShadow = true
|
|
151
|
-
this.object3d.onBeforeRender = () => {
|
|
152
|
-
this.onBeforeRender()
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
onchangeStockData(data: any) {
|
|
157
|
-
this.object3d.userData = {
|
|
158
|
-
...this.object3d.userData,
|
|
159
|
-
data
|
|
160
|
-
}
|
|
161
|
-
var visualizer = this.visualizer
|
|
162
|
-
|
|
163
|
-
if (!(visualizer && visualizer && visualizer!.legendTarget && visualizer!.legendTarget.getState('status'))) return
|
|
164
|
-
|
|
165
|
-
var stockStatus = visualizer!.legendTarget.getState('status') as {
|
|
166
|
-
field: string
|
|
167
|
-
ranges: { min: number; max: number }[]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var statusField = stockStatus.field
|
|
171
|
-
var ranges = stockStatus.ranges
|
|
172
|
-
|
|
173
|
-
if (!(statusField && ranges)) return
|
|
174
|
-
|
|
175
|
-
var items = data.items
|
|
176
|
-
|
|
177
|
-
if (!items) {
|
|
178
|
-
this.object3d.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
for (let item of items) {
|
|
183
|
-
var status = item && item[statusField]
|
|
184
|
-
|
|
185
|
-
if (status == undefined) {
|
|
186
|
-
this.object3d.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
var isInRanges = ranges.some((range, index) => {
|
|
191
|
-
let { min, max } = range
|
|
192
|
-
|
|
193
|
-
min = Number(min) || min
|
|
194
|
-
max = Number(max) || max
|
|
195
|
-
|
|
196
|
-
if (max > status) {
|
|
197
|
-
if (min !== undefined) {
|
|
198
|
-
if (min <= status) {
|
|
199
|
-
this.object3d.material = this.getMaterial(index)
|
|
200
|
-
} else return false
|
|
201
|
-
} else {
|
|
202
|
-
this.object3d.material = this.getMaterial(index)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return true
|
|
206
|
-
} else {
|
|
207
|
-
this.object3d.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
if (!isInRanges) {
|
|
211
|
-
this.object3d.material = this.userDefineDefaultMaterial
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
onBeforeRender = () => {
|
|
217
|
-
if (this._focused) {
|
|
218
|
-
var lastTime = performance.now() - this._focusedAt!
|
|
219
|
-
var progress = lastTime / 2000
|
|
220
|
-
|
|
221
|
-
this.object3d.rotation.y = 2 * Math.PI * progress
|
|
222
|
-
this.component.invalidate()
|
|
223
|
-
} else if (this._focusedAt) {
|
|
224
|
-
delete this._focusedAt
|
|
225
|
-
this.object3d.rotation.y = 0
|
|
226
|
-
this.component.invalidate()
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
onmouseup(e: MouseEvent, visualizer: Visualizer, callback: (arg: { data: any; location: string }) => void) {
|
|
231
|
-
if (!this.object3d.visible) return
|
|
232
|
-
|
|
233
|
-
if (!this.object3d.userData || !this.object3d.userData.data)
|
|
234
|
-
this.object3d.userData = {
|
|
235
|
-
...this.object3d.userData,
|
|
236
|
-
data: {
|
|
237
|
-
loc: this.object3d.name,
|
|
238
|
-
items: [
|
|
239
|
-
{
|
|
240
|
-
loc: this.object3d.name
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (callback && typeof callback == 'function') {
|
|
247
|
-
callback({
|
|
248
|
-
...this.object3d.userData.data,
|
|
249
|
-
color: '#' + (this.object3d.material as any).color?.getHexString()
|
|
250
|
-
})
|
|
251
|
-
}
|
|
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() {}
|
|
262
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const icon = new URL('../../icons/3d-container.png', import.meta.url).href
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: '3d-container',
|
|
5
|
-
description: '3D Container',
|
|
6
|
-
group: '3D' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
|
|
7
|
-
icon,
|
|
8
|
-
model: {
|
|
9
|
-
type: '3d-container',
|
|
10
|
-
left: 100,
|
|
11
|
-
top: 100,
|
|
12
|
-
width: 800,
|
|
13
|
-
height: 600,
|
|
14
|
-
fillStyle: 'darkgray',
|
|
15
|
-
fov: 60,
|
|
16
|
-
near: 10,
|
|
17
|
-
far: 10000,
|
|
18
|
-
zoom: 100,
|
|
19
|
-
threed: false
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/templates/banner.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const icon = new URL('../../icons/banner.png', import.meta.url).href
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: 'banner',
|
|
5
|
-
description: '3D banner',
|
|
6
|
-
group: '3D' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
|
|
7
|
-
icon,
|
|
8
|
-
model: {
|
|
9
|
-
type: 'banner',
|
|
10
|
-
cx: 100,
|
|
11
|
-
cy: 100,
|
|
12
|
-
zPos: 0,
|
|
13
|
-
width: 100,
|
|
14
|
-
height: 10,
|
|
15
|
-
depth: 50,
|
|
16
|
-
fillStyle: '#ffffff',
|
|
17
|
-
strokeStyle: '#999',
|
|
18
|
-
lineWidth: 1,
|
|
19
|
-
alpha: 1
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/templates/camera.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const icon = new URL('../../icons/camera.png', import.meta.url).href
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: 'camera',
|
|
5
|
-
description: '3D camera',
|
|
6
|
-
group: '3D' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
|
|
7
|
-
icon,
|
|
8
|
-
model: {
|
|
9
|
-
type: 'camera',
|
|
10
|
-
left: 100,
|
|
11
|
-
top: 100,
|
|
12
|
-
width: 100,
|
|
13
|
-
height: 100,
|
|
14
|
-
depth: 50,
|
|
15
|
-
fillStyle: '#CCAA76',
|
|
16
|
-
strokeStyle: '#999',
|
|
17
|
-
lineWidth: 1,
|
|
18
|
-
alpha: 1,
|
|
19
|
-
far: 100000,
|
|
20
|
-
fov: 80,
|
|
21
|
-
near: 1,
|
|
22
|
-
zoom: 1,
|
|
23
|
-
showHelper: true
|
|
24
|
-
}
|
|
25
|
-
}
|