@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
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
import { Component } from '@hatiolab/things-scene'
|
|
3
|
-
|
|
4
|
-
import { createCanvas } from '../html/elements'
|
|
5
|
-
|
|
6
|
-
function nextPowerOf2(n: number) {
|
|
7
|
-
var count = 0
|
|
8
|
-
|
|
9
|
-
if (n && !(n & (n - 1))) {
|
|
10
|
-
return n
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
while (n != 0) {
|
|
14
|
-
n >>= 1
|
|
15
|
-
count += 1
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return 1 << count
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createCanvasTexture(component: Component): THREE.Texture {
|
|
22
|
-
var { lineWidth = 0 } = component.state
|
|
23
|
-
var { width, height } = component.bounds
|
|
24
|
-
|
|
25
|
-
width += lineWidth
|
|
26
|
-
height += lineWidth
|
|
27
|
-
|
|
28
|
-
// Factor for increasing image resolution.
|
|
29
|
-
// TODO to be able to redraw according to the change in zoom value.
|
|
30
|
-
const scale = 2 // component.realObject?.threeContainer?.zoom as number
|
|
31
|
-
|
|
32
|
-
var poweredWidth = nextPowerOf2(width * scale)
|
|
33
|
-
var poweredHeight = nextPowerOf2(height * scale)
|
|
34
|
-
|
|
35
|
-
let canvas = createCanvas(poweredWidth, poweredHeight)
|
|
36
|
-
|
|
37
|
-
var texture = new THREE.CanvasTexture(canvas)
|
|
38
|
-
|
|
39
|
-
renderCanvasTexture(canvas, component, scale)
|
|
40
|
-
|
|
41
|
-
texture.needsUpdate = true
|
|
42
|
-
texture.wrapS = THREE.RepeatWrapping
|
|
43
|
-
texture.wrapT = THREE.RepeatWrapping
|
|
44
|
-
texture.offset.set(0, 1 - (height * scale) / poweredHeight)
|
|
45
|
-
texture.repeat.set((width * scale) / poweredWidth, (height * scale) / poweredHeight)
|
|
46
|
-
texture.magFilter = THREE.NearestFilter
|
|
47
|
-
texture.minFilter = THREE.LinearFilter
|
|
48
|
-
// texture.minFilter = THREE.LinearMipMapLinearFilter
|
|
49
|
-
texture.colorSpace = THREE.SRGBColorSpace
|
|
50
|
-
|
|
51
|
-
return texture
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function renderCanvasTexture(canvas: HTMLCanvasElement, component: Component, scale: number) {
|
|
55
|
-
var { lineWidth = 0 } = component.state
|
|
56
|
-
var { left, top } = component.bounds
|
|
57
|
-
|
|
58
|
-
left -= lineWidth / 2
|
|
59
|
-
top -= lineWidth / 2
|
|
60
|
-
|
|
61
|
-
let context = canvas.getContext('2d')
|
|
62
|
-
|
|
63
|
-
context!.scale(scale, scale)
|
|
64
|
-
context!.translate(-left, -top)
|
|
65
|
-
component.render(context!)
|
|
66
|
-
component.postrender(context!)
|
|
67
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
|
|
3
|
-
import { createCanvas } from '../html/elements'
|
|
4
|
-
|
|
5
|
-
export function fontStyle(bold: boolean, italic: boolean, fontSize: number, fontFamily: string): string {
|
|
6
|
-
return [
|
|
7
|
-
['bold', bold],
|
|
8
|
-
['italic', italic],
|
|
9
|
-
[fontSize + 'px', true],
|
|
10
|
-
[fontFamily, true]
|
|
11
|
-
]
|
|
12
|
-
.filter(p => p[1])
|
|
13
|
-
.map(p => p[0])
|
|
14
|
-
.join(' ')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function nextPowerOf2(n: number) {
|
|
18
|
-
var count = 0
|
|
19
|
-
|
|
20
|
-
if (n && !(n & (n - 1))) {
|
|
21
|
-
return n
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
while (n != 0) {
|
|
25
|
-
n >>= 1
|
|
26
|
-
count += 1
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return 1 << count
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function drawTextTexture(canvas: HTMLCanvasElement, text: string, textStyle: any) {
|
|
33
|
-
var { bold = false, italic = false, fontFamily = 'Serif', fontSize = 10, fontColor = 'black' } = textStyle || {}
|
|
34
|
-
|
|
35
|
-
var ctx = canvas.getContext('2d')
|
|
36
|
-
ctx!.imageSmoothingEnabled = false
|
|
37
|
-
|
|
38
|
-
ctx!.fillStyle = fontColor
|
|
39
|
-
ctx!.strokeStyle = fontColor
|
|
40
|
-
ctx!.font = fontStyle(bold, italic, fontSize, fontFamily)
|
|
41
|
-
ctx!.textBaseline = 'top'
|
|
42
|
-
ctx!.textAlign = 'left'
|
|
43
|
-
ctx!.fillText(String(text), 0, 0)
|
|
44
|
-
|
|
45
|
-
/* TODO multiline 시 검토 */
|
|
46
|
-
// var lineText = String(text).split('\n')
|
|
47
|
-
// lineText.forEach((t, i) => {
|
|
48
|
-
// ctx.fillText(t, 0, Number(i) * lineHeight)
|
|
49
|
-
// ctx.strokeText(t, 0, Number(i) * lineHeight)
|
|
50
|
-
// })
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function textTexture(text: string, width: number, height: number, textStyle: any) {
|
|
54
|
-
// TODO component.text의 heavy한 로직을 반복적으로 실행하지 않도록, 캐싱하자.
|
|
55
|
-
var poweredWidth = nextPowerOf2(width)
|
|
56
|
-
var poweredHeight = nextPowerOf2(height)
|
|
57
|
-
|
|
58
|
-
let canvas = createCanvas(poweredWidth, poweredHeight)
|
|
59
|
-
|
|
60
|
-
drawTextTexture(canvas, text, textStyle)
|
|
61
|
-
|
|
62
|
-
var texture = new THREE.CanvasTexture(canvas)
|
|
63
|
-
|
|
64
|
-
texture.needsUpdate = true
|
|
65
|
-
texture.wrapS = THREE.RepeatWrapping
|
|
66
|
-
texture.wrapT = THREE.RepeatWrapping
|
|
67
|
-
texture.offset.set(0, 1 - height / poweredHeight)
|
|
68
|
-
texture.repeat.set(width / poweredWidth, height / poweredHeight)
|
|
69
|
-
texture.minFilter = THREE.LinearFilter
|
|
70
|
-
|
|
71
|
-
return texture
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function textBounds(text: string, textStyle: any): { width: number; height: number } {
|
|
75
|
-
let { bold = false, italic = false, fontFamily = 'Serif', fontSize = 10, lineHeight = 'normal' } = textStyle || {}
|
|
76
|
-
|
|
77
|
-
if (text === undefined || text == '') {
|
|
78
|
-
text = ' '
|
|
79
|
-
} else {
|
|
80
|
-
text = String(text)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let span = document.createElement('span')
|
|
84
|
-
span.style.font = fontStyle(bold, italic, fontSize, fontFamily)
|
|
85
|
-
span.style.lineHeight = String(lineHeight)
|
|
86
|
-
span.style.whiteSpace = 'pre'
|
|
87
|
-
span.style.position = 'absolute'
|
|
88
|
-
span.textContent = text
|
|
89
|
-
|
|
90
|
-
document.body.appendChild(span)
|
|
91
|
-
|
|
92
|
-
let textBounds = span.getBoundingClientRect()
|
|
93
|
-
|
|
94
|
-
document.body.removeChild(span)
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
width: textBounds.width,
|
|
98
|
-
height: textBounds.height
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Component } from '@hatiolab/things-scene'
|
|
2
|
-
|
|
3
|
-
export interface ThreeDimensionalContainer extends Component {
|
|
4
|
-
is3dContainer(): boolean
|
|
5
|
-
get scene3d(): THREE.Scene | undefined
|
|
6
|
-
get renderer3d(): THREE.WebGLRenderer | undefined
|
|
7
|
-
get mixer(): THREE.AnimationMixer | undefined
|
|
8
|
-
get zoom(): number | undefined
|
|
9
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
|
|
3
|
-
type ExtrudedOptions = {
|
|
4
|
-
depth: number
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export class BoundUVGenerator {
|
|
8
|
-
bb?: THREE.Box2
|
|
9
|
-
extrudedShape?: THREE.Shape
|
|
10
|
-
extrudedOptions?: ExtrudedOptions
|
|
11
|
-
|
|
12
|
-
setShape({ extrudedShape, extrudedOptions }: { extrudedShape: THREE.Shape; extrudedOptions: ExtrudedOptions }) {
|
|
13
|
-
this.extrudedShape = extrudedShape
|
|
14
|
-
this.bb = new THREE.Box2()
|
|
15
|
-
|
|
16
|
-
this.bb.setFromPoints(this.extrudedShape?.extractPoints(0).shape)
|
|
17
|
-
this.extrudedOptions = extrudedOptions
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
generateTopUV(geometry: THREE.BufferGeometry, vertices: number[], indexA: number, indexB: number, indexC: number) {
|
|
21
|
-
const ax = vertices[indexA * 3],
|
|
22
|
-
ay = vertices[indexA * 3 + 1],
|
|
23
|
-
bx = vertices[indexB * 3],
|
|
24
|
-
by = vertices[indexB * 3 + 1],
|
|
25
|
-
cx = vertices[indexC * 3],
|
|
26
|
-
cy = vertices[indexC * 3 + 1],
|
|
27
|
-
bb = this.bb!, //extrudedShape.getBoundingBox(),
|
|
28
|
-
bbx = bb.max.x - bb.min.x,
|
|
29
|
-
bby = bb.max.y - bb.min.y
|
|
30
|
-
|
|
31
|
-
return [
|
|
32
|
-
new THREE.Vector2((ax - bb.min.x) / bbx, 1.0 - (ay - bb.min.y) / bby),
|
|
33
|
-
new THREE.Vector2((bx - bb.min.x) / bbx, 1.0 - (by - bb.min.y) / bby),
|
|
34
|
-
new THREE.Vector2((cx - bb.min.x) / bbx, 1.0 - (cy - bb.min.y) / bby)
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
generateSideWallUV(
|
|
39
|
-
geometry: THREE.BufferGeometry,
|
|
40
|
-
vertices: number[],
|
|
41
|
-
indexA: number,
|
|
42
|
-
indexB: number,
|
|
43
|
-
indexC: number,
|
|
44
|
-
indexD: number
|
|
45
|
-
) {
|
|
46
|
-
const ax = vertices[indexA * 3],
|
|
47
|
-
ay = vertices[indexA * 3 + 1],
|
|
48
|
-
az = vertices[indexA * 3 + 2],
|
|
49
|
-
bx = vertices[indexB * 3],
|
|
50
|
-
by = vertices[indexB * 3 + 1],
|
|
51
|
-
bz = vertices[indexB * 3 + 2],
|
|
52
|
-
cx = vertices[indexC * 3],
|
|
53
|
-
cy = vertices[indexC * 3 + 1],
|
|
54
|
-
cz = vertices[indexC * 3 + 2],
|
|
55
|
-
dx = vertices[indexD * 3],
|
|
56
|
-
dy = vertices[indexD * 3 + 1],
|
|
57
|
-
dz = vertices[indexD * 3 + 2]
|
|
58
|
-
|
|
59
|
-
const amt = this.extrudedOptions?.depth || 100,
|
|
60
|
-
bb = this.bb!, //extrudedShape.getBoundingBox(),
|
|
61
|
-
bbx = bb.max.x - bb.min.x,
|
|
62
|
-
bby = bb.max.y - bb.min.y
|
|
63
|
-
|
|
64
|
-
if (Math.abs(ay - by) < 0.01) {
|
|
65
|
-
return [
|
|
66
|
-
new THREE.Vector2(ax / bbx, 1.0 - az / amt),
|
|
67
|
-
new THREE.Vector2(bx / bbx, 1.0 - bz / amt),
|
|
68
|
-
new THREE.Vector2(cx / bbx, 1.0 - cz / amt),
|
|
69
|
-
new THREE.Vector2(dx / bbx, 1.0 - dz / amt)
|
|
70
|
-
]
|
|
71
|
-
} else {
|
|
72
|
-
return [
|
|
73
|
-
new THREE.Vector2(ay / bby, 1.0 - az / amt),
|
|
74
|
-
new THREE.Vector2(by / bby, 1.0 - bz / amt),
|
|
75
|
-
new THREE.Vector2(cy / bby, 1.0 - cz / amt),
|
|
76
|
-
new THREE.Vector2(dy / bby, 1.0 - dz / amt)
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
package/src/visualizer.ts
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Component, ScenePopup, Properties, ComponentNature } from '@hatiolab/things-scene'
|
|
6
|
-
import * as THREE from 'three'
|
|
7
|
-
|
|
8
|
-
import { RealObject } from './threed/real-object'
|
|
9
|
-
import './three-layout'
|
|
10
|
-
import { ThreeContainer } from './three-container'
|
|
11
|
-
import { Stock } from './stock'
|
|
12
|
-
|
|
13
|
-
const NATURE: ComponentNature = {
|
|
14
|
-
mutable: false,
|
|
15
|
-
resizable: true,
|
|
16
|
-
rotatable: true,
|
|
17
|
-
properties: [
|
|
18
|
-
{
|
|
19
|
-
type: 'number',
|
|
20
|
-
label: 'fov',
|
|
21
|
-
name: 'fov',
|
|
22
|
-
property: 'fov'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
type: 'number',
|
|
26
|
-
label: 'near',
|
|
27
|
-
name: 'near',
|
|
28
|
-
property: 'near'
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: 'number',
|
|
32
|
-
label: 'far',
|
|
33
|
-
name: 'far',
|
|
34
|
-
property: 'far'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: 'number',
|
|
38
|
-
label: 'zoom',
|
|
39
|
-
name: 'zoom',
|
|
40
|
-
property: 'zoom'
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: 'number',
|
|
44
|
-
label: 'camera-x',
|
|
45
|
-
name: 'cameraX'
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
type: 'number',
|
|
49
|
-
label: 'camera-y',
|
|
50
|
-
name: 'cameraY'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: 'number',
|
|
54
|
-
label: 'camera-z',
|
|
55
|
-
name: 'cameraZ'
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'select',
|
|
59
|
-
label: 'precision',
|
|
60
|
-
name: 'precision',
|
|
61
|
-
property: {
|
|
62
|
-
options: [
|
|
63
|
-
{
|
|
64
|
-
display: 'High',
|
|
65
|
-
value: 'highp'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
display: 'Medium',
|
|
69
|
-
value: 'mediump'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
display: 'Low',
|
|
73
|
-
value: 'lowp'
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
type: 'checkbox',
|
|
80
|
-
label: 'anti-alias',
|
|
81
|
-
name: 'antialias',
|
|
82
|
-
property: 'antialias'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
type: 'checkbox',
|
|
86
|
-
label: 'auto-rotate',
|
|
87
|
-
name: 'autoRotate',
|
|
88
|
-
property: 'autoRotate'
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
type: 'checkbox',
|
|
92
|
-
label: '3dmode',
|
|
93
|
-
name: 'threed',
|
|
94
|
-
property: 'threed'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: 'checkbox',
|
|
98
|
-
label: 'debug',
|
|
99
|
-
name: 'debug',
|
|
100
|
-
property: 'debug'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: 'string',
|
|
104
|
-
label: 'location-field',
|
|
105
|
-
name: 'locationField',
|
|
106
|
-
placeholder: 'location'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: 'board-selector',
|
|
110
|
-
label: 'popup-scene',
|
|
111
|
-
name: 'popupScene'
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
type: 'id-input',
|
|
115
|
-
label: 'legend-target',
|
|
116
|
-
name: 'legendTarget',
|
|
117
|
-
property: {
|
|
118
|
-
component: 'legend'
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
type: 'number',
|
|
123
|
-
label: 'rotation-speed',
|
|
124
|
-
name: 'rotationSpeed'
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
type: 'checkbox',
|
|
128
|
-
label: 'hide-empty-stock',
|
|
129
|
-
name: 'hideEmptyStock'
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
type: 'select',
|
|
133
|
-
label: 'popup-position',
|
|
134
|
-
name: 'popupPosition',
|
|
135
|
-
property: {
|
|
136
|
-
options: [
|
|
137
|
-
{ display: '', value: '' },
|
|
138
|
-
{ display: 'CENTER', value: 'center' },
|
|
139
|
-
{ display: 'LEFTTOP', value: 'left-top' },
|
|
140
|
-
{ display: 'RIGHTTOP', value: 'right-top' },
|
|
141
|
-
{ display: 'LEFTBOTTOM', value: 'left-bottom' },
|
|
142
|
-
{ display: 'RIGHTBOTTOM', value: 'right-bottom' }
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
help: 'scene/component/visualizer'
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const WEBGL_NO_SUPPORT_TEXT = 'WebGL no support'
|
|
151
|
-
|
|
152
|
-
export class Visualizer extends ThreeContainer {
|
|
153
|
-
_legendTarget?: Component
|
|
154
|
-
|
|
155
|
-
_objects: { [id: string]: RealObject } = {}
|
|
156
|
-
|
|
157
|
-
_stock_materials: THREE.Material[] = []
|
|
158
|
-
_default_material?: THREE.Material /* only for Stock */
|
|
159
|
-
_empty_material?: THREE.Material /* only for Stock */
|
|
160
|
-
|
|
161
|
-
get legendTarget() {
|
|
162
|
-
var { legendTarget } = this.state
|
|
163
|
-
|
|
164
|
-
if (!this._legendTarget && legendTarget) {
|
|
165
|
-
this._legendTarget = this.root.findById(legendTarget)
|
|
166
|
-
this._legendTarget && this._legendTarget.on('change', this.onLegendTargetChanged, this)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return this._legendTarget
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
putObject(id: string, object: RealObject) {
|
|
173
|
-
id && (this._objects[id] = object)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
getObject(id: string): RealObject {
|
|
177
|
-
return this._objects[id]
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/* Container Overides .. */
|
|
181
|
-
|
|
182
|
-
dispose() {
|
|
183
|
-
this._legendTarget && this._legendTarget.off('change', this.onLegendTargetChanged, this)
|
|
184
|
-
delete this._legendTarget
|
|
185
|
-
|
|
186
|
-
super.dispose()
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
get nature(): ComponentNature {
|
|
190
|
-
return NATURE
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
resetMaterials() {
|
|
194
|
-
this._stock_materials.forEach(m => {
|
|
195
|
-
if (m.dispose) m.dispose()
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
this._stock_materials = []
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/* Event Handlers */
|
|
202
|
-
|
|
203
|
-
onchange(after: Properties, before: Properties) {
|
|
204
|
-
if (before.hasOwnProperty('legendTarget') || after.hasOwnProperty('legendTarget')) {
|
|
205
|
-
this._legendTarget && this._legendTarget.off('change', this.onLegendTargetChanged, this)
|
|
206
|
-
delete this._legendTarget
|
|
207
|
-
this.resetMaterials()
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
super.onchange(after, before)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
onchangeData(): void {
|
|
214
|
-
if (typeof this.data !== 'object') {
|
|
215
|
-
return
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
var data = this.data
|
|
219
|
-
var locationField = this.getState('locationField') || 'location'
|
|
220
|
-
|
|
221
|
-
if (data instanceof Array) {
|
|
222
|
-
/**
|
|
223
|
-
* Array type data
|
|
224
|
-
* (e.g. data: [{
|
|
225
|
-
* 'location' : 'A0101-01',
|
|
226
|
-
* 'description': 'description1',
|
|
227
|
-
* ...
|
|
228
|
-
* }, {
|
|
229
|
-
* ...
|
|
230
|
-
* }])
|
|
231
|
-
*/
|
|
232
|
-
|
|
233
|
-
data = data.reduce((acc, value, i, arr) => {
|
|
234
|
-
var location = value[locationField]
|
|
235
|
-
|
|
236
|
-
if (!location) {
|
|
237
|
-
return acc
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// 하나의 로케이션에 여러 레코드 정보가 올 수 있으므로, 하나이 로케이션의 스탁정보를 items 배열에 담는다.
|
|
241
|
-
if (acc[location]) {
|
|
242
|
-
acc[location]['items'].push(value)
|
|
243
|
-
} else {
|
|
244
|
-
acc[location] = { items: [value] }
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return acc
|
|
248
|
-
}, {})
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Object type data
|
|
253
|
-
* (e.g. data: {
|
|
254
|
-
* 'A0101-01': { items: [{ location: 'A0101-01', qty: 10, description: 'description', ... }, {...}] },
|
|
255
|
-
* ...
|
|
256
|
-
* })
|
|
257
|
-
*/
|
|
258
|
-
for (var key in data) {
|
|
259
|
-
let id = key
|
|
260
|
-
if (data.hasOwnProperty(id)) {
|
|
261
|
-
let d = data[id]
|
|
262
|
-
let object = this.getObject(id)
|
|
263
|
-
if (object) {
|
|
264
|
-
;(object as Stock).onchangeStockData(d)
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
onLegendTargetChanged(after: { [key: string]: any }, before: { [key: string]: any }) {
|
|
271
|
-
if (after.hasOwnProperty('status') && before.hasOwnProperty('status')) this.resetMaterials()
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
onmouseup(e: MouseEvent) {
|
|
275
|
-
if (this._controls) {
|
|
276
|
-
if (this._lastFocused) {
|
|
277
|
-
;(this._lastFocused as any)._focused = false
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const { popupScene, left, top, width, height } = this.state
|
|
281
|
-
|
|
282
|
-
var ref = popupScene
|
|
283
|
-
var pointer = this.transcoordC2S(e.offsetX, e.offsetY)
|
|
284
|
-
|
|
285
|
-
this._mouse!.x = ((pointer.x - left) / width) * 2 - 1
|
|
286
|
-
this._mouse!.y = -((pointer.y - top) / height) * 2 + 1
|
|
287
|
-
|
|
288
|
-
var object = this.getObjectByRaycast()
|
|
289
|
-
var realObject = object?.userData.context
|
|
290
|
-
|
|
291
|
-
if (realObject) {
|
|
292
|
-
if (ref && realObject instanceof Stock) {
|
|
293
|
-
;(realObject as any).onmouseup(e, this, (data: any) => {
|
|
294
|
-
ScenePopup.show(this, ref, {
|
|
295
|
-
data,
|
|
296
|
-
modal: false,
|
|
297
|
-
closable: true,
|
|
298
|
-
output: false,
|
|
299
|
-
location: this.state.popupPosition || 'right-top'
|
|
300
|
-
})
|
|
301
|
-
})
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
;(realObject as any)._focused = true
|
|
305
|
-
;(realObject as any)._focusedAt = performance.now()
|
|
306
|
-
this._lastFocused = realObject
|
|
307
|
-
realObject.component?.trigger('click', e)
|
|
308
|
-
} else {
|
|
309
|
-
ScenePopup.hide(this.root)
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
this.invalidate()
|
|
313
|
-
|
|
314
|
-
e.stopPropagation()
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
Component.register('visualizer', Visualizer)
|
package/src/wall.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { Component, ComponentNature, Properties, RectPath, Shape } 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
|
-
{
|
|
15
|
-
type: 'number',
|
|
16
|
-
label: 'depth',
|
|
17
|
-
name: 'depth',
|
|
18
|
-
property: 'depth'
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
help: 'scene/component/wall'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class Wall3D extends RealObjectMesh {
|
|
25
|
-
buildGeometry() {
|
|
26
|
-
this.object3d.geometry = new THREE.BoxGeometry(1, 1, 1)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
updateDimension(): void {
|
|
30
|
-
var { width, height, depth = 1 } = this.component.state
|
|
31
|
-
|
|
32
|
-
this.object3d.scale.set(width, depth, height)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class Wall extends RectPath(Shape) {
|
|
37
|
-
is3dish() {
|
|
38
|
-
return true
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
buildRealObject(): RealObject | undefined {
|
|
42
|
-
return new Wall3D(this)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get nature() {
|
|
46
|
-
return NATURE
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
Component.register('wall', Wall)
|
package/tsconfig.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2018",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"lib": ["es2019", "dom"],
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": false,
|
|
10
|
-
"allowJs": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"experimentalDecorators": true,
|
|
13
|
-
"importHelpers": true,
|
|
14
|
-
"outDir": "dist",
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"inlineSources": true,
|
|
17
|
-
"rootDir": "src",
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"incremental": true,
|
|
20
|
-
"skipLibCheck": true,
|
|
21
|
-
"types": []
|
|
22
|
-
},
|
|
23
|
-
"include": ["**/*.ts", "**/*.d.ts"]
|
|
24
|
-
}
|