@operato/scene-wheel-sorter 0.0.11

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 (70) hide show
  1. package/@types/global/index.d.ts +1 -0
  2. package/CHANGELOG.md +12 -0
  3. package/LICENSE +21 -0
  4. package/README.md +33 -0
  5. package/assets/conveyor-belt.png +0 -0
  6. package/assets/conveyor-join-trapezoid.png +0 -0
  7. package/assets/conveyor-join.png +0 -0
  8. package/assets/conveyor.png +0 -0
  9. package/assets/scanner.png +0 -0
  10. package/assets/wheel-sorter.png +0 -0
  11. package/dist/conveyor-join-trapezoid.d.ts +41 -0
  12. package/dist/conveyor-join-trapezoid.js +63 -0
  13. package/dist/conveyor-join-trapezoid.js.map +1 -0
  14. package/dist/conveyor-join.d.ts +49 -0
  15. package/dist/conveyor-join.js +142 -0
  16. package/dist/conveyor-join.js.map +1 -0
  17. package/dist/conveyor.d.ts +41 -0
  18. package/dist/conveyor.js +62 -0
  19. package/dist/conveyor.js.map +1 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.js +9 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/mixin-conveyor.d.ts +16 -0
  24. package/dist/mixin-conveyor.js +121 -0
  25. package/dist/mixin-conveyor.js.map +1 -0
  26. package/dist/mixin-scanner.d.ts +15 -0
  27. package/dist/mixin-scanner.js +99 -0
  28. package/dist/mixin-scanner.js.map +1 -0
  29. package/dist/mixin-wheel-sorter.d.ts +12 -0
  30. package/dist/mixin-wheel-sorter.js +92 -0
  31. package/dist/mixin-wheel-sorter.js.map +1 -0
  32. package/dist/scanner.d.ts +28 -0
  33. package/dist/scanner.js +46 -0
  34. package/dist/scanner.js.map +1 -0
  35. package/dist/templates/index.d.ts +173 -0
  36. package/dist/templates/index.js +123 -0
  37. package/dist/templates/index.js.map +1 -0
  38. package/dist/wheel-sorter.d.ts +27 -0
  39. package/dist/wheel-sorter.js +54 -0
  40. package/dist/wheel-sorter.js.map +1 -0
  41. package/helps/scene/component/conveyor-join-trapezoid.ko.md +6 -0
  42. package/helps/scene/component/conveyor-join-trapezoid.md +6 -0
  43. package/helps/scene/component/conveyor-join-trapezoid.zh.md +6 -0
  44. package/helps/scene/component/conveyor-join.ko.md +6 -0
  45. package/helps/scene/component/conveyor-join.md +6 -0
  46. package/helps/scene/component/conveyor-join.zh.md +6 -0
  47. package/helps/scene/component/conveyor.ko.md +6 -0
  48. package/helps/scene/component/conveyor.md +6 -0
  49. package/helps/scene/component/conveyor.zh.md +6 -0
  50. package/helps/scene/component/wheel-sorter.ko.md +6 -0
  51. package/helps/scene/component/wheel-sorter.md +6 -0
  52. package/helps/scene/component/wheel-sorter.zh.md +6 -0
  53. package/package.json +62 -0
  54. package/src/conveyor-join-trapezoid.ts +69 -0
  55. package/src/conveyor-join.ts +170 -0
  56. package/src/conveyor.ts +69 -0
  57. package/src/index.ts +8 -0
  58. package/src/mixin-conveyor.ts +169 -0
  59. package/src/mixin-scanner.ts +122 -0
  60. package/src/mixin-wheel-sorter.ts +117 -0
  61. package/src/scanner.ts +54 -0
  62. package/src/templates/index.ts +123 -0
  63. package/src/wheel-sorter.ts +63 -0
  64. package/test/basic-test.html +67 -0
  65. package/test/index.html +22 -0
  66. package/test/unit/test-conveyor.js +35 -0
  67. package/test/unit/util.js +21 -0
  68. package/things-scene.config.js +5 -0
  69. package/tsconfig.json +23 -0
  70. package/tsconfig.tsbuildinfo +1 -0
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export { default as Conveyor } from './conveyor'
5
+ export { default as ConveyorJoin } from './conveyor-join'
6
+ export { default as ConveyorJoinTrapezoid } from './conveyor-join-trapezoid'
7
+ export { default as WheelSorter } from './wheel-sorter'
8
+ export { default as Scanner } from './scanner'
@@ -0,0 +1,169 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { Class, Component, ValueHolder } from '@hatiolab/things-scene'
5
+
6
+ const TYPE_ROLLER = 0
7
+ const TYPE_BELT = 1
8
+
9
+ const FILL_STYLES = ['#ccc', '#afd0f1', '#afd0f1', '#ffba00', '#e9746b'] // IDLE, RUN, RUN(REVERSE), WARN, ERROR
10
+ const STROKE_STYLES = ['#999', '#87b1db', '#87b1db', '#d96f21', '#a73928'] // IDLE, RUN, RUN(REVERSE), WARN, ERROR
11
+
12
+ type RollerPattern = {
13
+ width: number
14
+ height: number
15
+ }
16
+
17
+ function pattern_for_belt_type(component: any) {
18
+ var { height } = component.bounds
19
+
20
+ var { rollWidth = 10 } = component.model
21
+
22
+ var width = Math.max(rollWidth, 1)
23
+
24
+ var color = FILL_STYLES[component.value] || FILL_STYLES[0]
25
+ var stroke = STROKE_STYLES[component.value] || STROKE_STYLES[0]
26
+ var lineWidth = 1
27
+
28
+ if (!component._roller_pattern) component._roller_pattern = document.createElement('canvas')
29
+
30
+ component._roller_pattern.width = width
31
+ component._roller_pattern.height = height
32
+
33
+ var context = component._roller_pattern.getContext('2d')
34
+
35
+ context.beginPath()
36
+ context.fillStyle = color
37
+ context.strokeStyle = stroke
38
+ context.lineWidth = lineWidth
39
+
40
+ context.moveTo(0, 0)
41
+ context.lineTo(width, 0)
42
+ context.lineTo(width, height)
43
+ context.lineTo(0, height)
44
+ context.lineTo(0, 0)
45
+ context.fill()
46
+
47
+ context.beginPath()
48
+
49
+ context.globalAlpha = 0.2
50
+
51
+ var x_for_belt = (component._step || 0) % width
52
+ if (component.value == 2) x_for_belt = width - x_for_belt
53
+
54
+ context.moveTo(x_for_belt, height)
55
+ context.lineTo(x_for_belt, 0)
56
+
57
+ context.stroke()
58
+
59
+ return component._roller_pattern
60
+ }
61
+
62
+ function pattern_for_roller_type(component: any) {
63
+ var { height } = component.bounds
64
+
65
+ var { rollWidth = 10, animated } = component.model
66
+
67
+ // var modelWidth = component.model.width;
68
+
69
+ var width = Math.max(rollWidth, 1)
70
+
71
+ var color = FILL_STYLES[component.value] || FILL_STYLES[0]
72
+ var stroke = STROKE_STYLES[component.value] || STROKE_STYLES[0]
73
+ var lineWidth = Math.min(1, width / 10)
74
+
75
+ width += lineWidth * 2
76
+
77
+ if (!component._roller_pattern) component._roller_pattern = document.createElement('canvas')
78
+
79
+ var gap = Math.floor((width * 2) / 3)
80
+
81
+ // while (Math.round(modelWidth - width) % (width + gap) > gap) {
82
+ // gap++
83
+ // console.log(gap, Math.round(modelWidth - width) % (width + gap))
84
+ // }
85
+
86
+ component._roller_pattern.width = width + gap
87
+ component._roller_pattern.height = height
88
+
89
+ var context = component._roller_pattern.getContext('2d')
90
+
91
+ context.beginPath()
92
+ context.fillStyle = color
93
+ context.strokeStyle = stroke
94
+ context.lineWidth = lineWidth
95
+
96
+ context.ellipse(lineWidth + width / 2, height - width / 4 - lineWidth, width / 2, width / 4, 0, 0, Math.PI)
97
+
98
+ context.moveTo(lineWidth, height - width / 4)
99
+ context.lineTo(lineWidth, width / 4)
100
+
101
+ context.ellipse(lineWidth + width / 2, width / 4 + lineWidth, width / 2, width / 4, 0, Math.PI, 0)
102
+
103
+ context.lineTo(lineWidth + width, height - width / 4)
104
+
105
+ context.fill()
106
+ context.stroke()
107
+
108
+ context.globalAlpha = 0.2
109
+
110
+ context.lineWidth = width / 3
111
+
112
+ if (animated) {
113
+ var x_for_roll = component._step % width
114
+ if (component.value == 2) x_for_roll = width - x_for_roll
115
+
116
+ context.moveTo(x_for_roll, height - width / 4)
117
+ context.lineTo(x_for_roll, width / 4)
118
+
119
+ context.stroke()
120
+ }
121
+
122
+ return component._roller_pattern
123
+ }
124
+
125
+ const patterns = [pattern_for_roller_type, pattern_for_belt_type]
126
+
127
+ export default (superclass: Class) => {
128
+ var A = class extends ValueHolder(superclass) {
129
+ dispose() {
130
+ super.dispose()
131
+ delete this._roller_pattern
132
+ }
133
+
134
+ animOnState() {
135
+ if ((this.value !== 1 && this.value !== 2) || this.disposed) return
136
+
137
+ if (!this._step || this._step > 40000) this._step = this.value == 0
138
+
139
+ this._step++
140
+
141
+ var self = this
142
+
143
+ requestAnimationFrame(function () {
144
+ self.clearCache('fillStyle')
145
+ self.invalidate()
146
+ })
147
+ }
148
+
149
+ get conveyorType() {
150
+ var conveyorType = this.get('conveyorType')
151
+ if (conveyorType != TYPE_BELT && conveyorType != TYPE_ROLLER) conveyorType = TYPE_ROLLER
152
+ return conveyorType
153
+ }
154
+
155
+ get fillStyle() {
156
+ return {
157
+ image: patterns[this.conveyorType](this),
158
+ offsetX: 0,
159
+ offsetY: 0,
160
+ type: 'pattern'
161
+ }
162
+ }
163
+ }
164
+
165
+ Component.memoize(A.prototype, 'fillStyle', false)
166
+ Component.memoize(A.prototype, 'conveyorType', false)
167
+
168
+ return A
169
+ }
@@ -0,0 +1,122 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { Class, Component, ValueHolder } from '@hatiolab/things-scene'
5
+
6
+ const FILL_STYLES = ['rgba(0,0,0,.4)', 'rgba(175,208,241,.7)', 'rgba(255,186,0,.7)', 'rgba(198,50,40,.7)'] // IDLE, RUN, WARN, ERROR
7
+ const STROKE_STYLES = ['rgba(0,0,0,.7)', 'rgba(175,208,241,1)', 'rgba(255,186,0,1)', 'rgba(198,50,40,1)'] // IDLE, RUN, WARN, ERROR
8
+
9
+ function pattern(component: any) {
10
+ var { width, height } = component.bounds
11
+
12
+ var color = FILL_STYLES[component.value] || FILL_STYLES[0]
13
+ var stroke = STROKE_STYLES[component.value] || STROKE_STYLES[0]
14
+ var lineWidth = 1
15
+
16
+ if (!component._scanner_pattern) component._scanner_pattern = document.createElement('canvas')
17
+
18
+ component._scanner_pattern.width = width
19
+ component._scanner_pattern.height = height
20
+
21
+ var ctx = component._scanner_pattern.getContext('2d')
22
+
23
+ var radius = width / 10
24
+ var left = 0
25
+ var top = 0
26
+
27
+ // outer box
28
+ ctx.beginPath()
29
+ ctx.fillStyle = color
30
+ ctx.strokeStyle = stroke
31
+
32
+ ctx.rect(0, 0, width, height)
33
+ ctx.fill()
34
+ // ctx.stroke();
35
+
36
+ // inner box
37
+ radius = width / 40
38
+ left = width / 4
39
+ top = height / 4
40
+
41
+ ctx.beginPath()
42
+ ctx.fillStyle = 'rgba(0,0,0,.7)'
43
+ ctx.strokeStyle = null
44
+
45
+ ctx.moveTo(left + radius, top)
46
+ ctx.lineTo(left + width / 2 - radius, top)
47
+ ctx.quadraticCurveTo(left + width / 2, top, left + width / 2, top + radius)
48
+ ctx.lineTo(left + width / 2, top + height / 2 - radius)
49
+ ctx.quadraticCurveTo(left + width / 2, top + height / 2, left + width / 2 - radius, top + height / 2)
50
+ ctx.lineTo(left + radius, top + height / 2)
51
+ ctx.quadraticCurveTo(left, top + height / 2, left, top + height / 2 - radius)
52
+ ctx.lineTo(left, top + radius)
53
+ ctx.quadraticCurveTo(left, top, left + radius, top)
54
+ ctx.fill()
55
+
56
+ // barcode
57
+ left = left + width * 0.1
58
+ top = top + height * 0.05
59
+
60
+ var offsetTop = 0
61
+ var barcodeAreaWidth = width * 0.3
62
+ var barcodeAreaHeight = height * 0.4
63
+
64
+ ctx.beginPath()
65
+ ctx.fillStyle = '#fff'
66
+
67
+ ctx.moveTo(left, top)
68
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, (barcodeAreaHeight / 14) * 0.9)
69
+ offsetTop = (barcodeAreaHeight / 14) * 2
70
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, (barcodeAreaHeight / 14) * 0.3)
71
+ offsetTop = (barcodeAreaHeight / 14) * 4
72
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, (barcodeAreaHeight / 14) * 0.4)
73
+ offsetTop = (barcodeAreaHeight / 14) * 6
74
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, (barcodeAreaHeight / 14) * 0.8)
75
+ offsetTop = (barcodeAreaHeight / 14) * 8
76
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, (barcodeAreaHeight / 14) * 0.6)
77
+ offsetTop = (barcodeAreaHeight / 14) * 10
78
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, barcodeAreaHeight / 14)
79
+ offsetTop = (barcodeAreaHeight / 14) * 11
80
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, barcodeAreaHeight / 14)
81
+ offsetTop = (barcodeAreaHeight / 14) * 14
82
+ ctx.rect(left, top + offsetTop, barcodeAreaWidth, (barcodeAreaHeight / 14) * 0.3)
83
+
84
+ ctx.fill()
85
+
86
+ // lazer
87
+ ctx.beginPath()
88
+ left = width / 2
89
+ top = height * 0.1
90
+
91
+ ctx.strokeStyle = '#cc3300'
92
+ ctx.lineWidth = 1
93
+ ctx.moveTo(left, top)
94
+ ctx.lineTo(left, height * 0.9)
95
+
96
+ ctx.stroke()
97
+
98
+ return component._scanner_pattern
99
+ }
100
+
101
+ export default (superclass: Class) => {
102
+ var A = class extends ValueHolder(superclass) {
103
+ dispose() {
104
+ super.dispose()
105
+ delete this._scanner_pattern
106
+ }
107
+
108
+ get fillStyle() {
109
+ return {
110
+ image: pattern(this),
111
+ offsetX: 0,
112
+ offsetY: 0,
113
+ type: 'pattern',
114
+ fitPattern: true
115
+ }
116
+ }
117
+ }
118
+
119
+ Component.memoize(A.prototype, 'fillStyle', false)
120
+
121
+ return A
122
+ }
@@ -0,0 +1,117 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { Class, Component, ValueHolder } from '@hatiolab/things-scene'
5
+
6
+ const FILL_STYLES = ['#ccc', '#afd0f1', '#ffba00', '#e9746b'] // IDLE, RUN, WARN, ERROR
7
+ const STROKE_STYLES = ['#999', '#87b1db', '#d96f21', '#a73928'] // IDLE, RUN, WARN, ERROR
8
+
9
+ export default (superclass: Class) => {
10
+ var A = class extends ValueHolder(superclass) {
11
+ animOnState() {
12
+ if (this.value !== 1 || this.disposed) return
13
+
14
+ var self = this
15
+
16
+ var alpha = Math.floor(Math.random() * 100)
17
+ if (alpha < 10) alpha = 2
18
+ else if (alpha > 90) alpha = 1
19
+ else alpha = 0
20
+
21
+ requestAnimationFrame(function () {
22
+ self.delta('tilt', alpha)
23
+ self.clearCache('fillStyle')
24
+ self.invalidate()
25
+ })
26
+ }
27
+
28
+ _draw_pattern(ctx: CanvasRenderingContext2D) {
29
+ var { width, height, left, top } = this.bounds
30
+
31
+ var { tilt = 0, wheelSize = 3 } = this.model
32
+
33
+ tilt += this.delta('tilt') || 0
34
+ tilt %= 3
35
+ tilt -= 1
36
+
37
+ var color = FILL_STYLES[this.value] || FILL_STYLES[0]
38
+ var stroke = STROKE_STYLES[this.value] || STROKE_STYLES[0]
39
+ var lineWidth = 1
40
+
41
+ var pattern_size = wheelSize * 10 || Math.min(width / 5, height / 5)
42
+
43
+ ctx.beginPath()
44
+ ctx.fillStyle = color
45
+ ctx.rect(left, top, width, height)
46
+ ctx.fill()
47
+
48
+ ctx.strokeStyle = stroke
49
+ ctx.lineWidth = lineWidth
50
+
51
+ this._draw_wheel(ctx, pattern_size, tilt)
52
+ }
53
+
54
+ _draw_circle(ctx: CanvasRenderingContext2D, size: number) {
55
+ var { width, height } = this.bounds
56
+
57
+ var offsetX = 0,
58
+ offsetY = 0
59
+
60
+ while (offsetY < height) {
61
+ offsetX = 0
62
+ while (offsetX < width) {
63
+ ctx.moveTo(offsetX + size / 2 + size / 3, offsetY + size / 2)
64
+ ctx.ellipse(offsetX + size / 2, offsetY + size / 2, size / 3, size / 3, 0, 0, 2 * Math.PI, false)
65
+
66
+ offsetX += size
67
+ }
68
+ offsetY += size
69
+ }
70
+
71
+ ctx.stroke()
72
+ }
73
+
74
+ _draw_inner(ctx: CanvasRenderingContext2D, size: number, tilt: number) {
75
+ var { width, height } = this.bounds
76
+
77
+ var offsetX = 0,
78
+ offsetY = 0
79
+
80
+ while (offsetY < height) {
81
+ offsetX = 0
82
+ while (offsetX < width) {
83
+ ctx.translate(offsetX, offsetY)
84
+ ctx.beginPath()
85
+ ctx.translate(size / 2, size / 2)
86
+ ctx.rotate(tilt)
87
+
88
+ ctx.moveTo(-size / 6, -size / 6)
89
+ ctx.lineTo(-size / 6, size / 6)
90
+ ctx.moveTo(size / 6, -size / 6)
91
+ ctx.lineTo(size / 6, size / 6)
92
+
93
+ ctx.stroke()
94
+ ctx.rotate(-tilt)
95
+ ctx.translate(-size / 2, -size / 2)
96
+ ctx.translate(-offsetX, -offsetY)
97
+
98
+ offsetX += size
99
+ }
100
+ offsetY += size
101
+ }
102
+ }
103
+
104
+ _draw_wheel(ctx: CanvasRenderingContext2D, size: number, tilt: number) {
105
+ var { left, top } = this.bounds
106
+
107
+ ctx.beginPath()
108
+ ctx.translate(left, top)
109
+ this._draw_circle(ctx, size)
110
+ this._draw_inner(ctx, size, tilt)
111
+ }
112
+ }
113
+
114
+ Component.memoize(A.prototype, 'fillStyle', false)
115
+
116
+ return A
117
+ }
package/src/scanner.ts ADDED
@@ -0,0 +1,54 @@
1
+ import { Component, RectPath, Shape } from '@hatiolab/things-scene'
2
+
3
+ /*
4
+ * Copyright © HatioLab Inc. All rights reserved.
5
+ */
6
+ import MixinScanner from './mixin-scanner'
7
+
8
+ const NATURE = {
9
+ mutable: false,
10
+ resizable: true,
11
+ rotatable: true,
12
+ properties: [
13
+ {
14
+ type: 'number',
15
+ label: 'value',
16
+ name: 'value'
17
+ }
18
+ ]
19
+ }
20
+
21
+ const STAT_IDLE = 0
22
+ const STAT_RUN = 1
23
+ const STAT_CHUTE_FULL = 2
24
+ const STAT_ERROR = 3
25
+
26
+ export default class Scanner extends MixinScanner(RectPath(Shape)) {
27
+ get nature() {
28
+ return NATURE
29
+ }
30
+
31
+ render(ctx: CanvasRenderingContext2D) {
32
+ var { width, height, left, top } = this.model
33
+
34
+ var radius = width / 10
35
+
36
+ ctx.beginPath()
37
+ ctx.moveTo(left + radius, top)
38
+ ctx.lineTo(left + width - radius, top)
39
+ ctx.quadraticCurveTo(left + width, top, left + width, top + radius)
40
+ ctx.lineTo(left + width, top + height - radius)
41
+ ctx.quadraticCurveTo(left + width, top + height, left + width - radius, top + height)
42
+ ctx.lineTo(left + radius, top + height)
43
+ ctx.quadraticCurveTo(left, top + height, left, top + height - radius)
44
+ ctx.lineTo(left, top + radius)
45
+ ctx.quadraticCurveTo(left, top, left + radius, top)
46
+ ctx.clip()
47
+ }
48
+
49
+ is3dish() {
50
+ return false
51
+ }
52
+ }
53
+
54
+ Component.register('scanner', Scanner as any)
@@ -0,0 +1,123 @@
1
+ import conveyor from '../../assets/conveyor.png'
2
+ import conveyorBelt from '../../assets/conveyor-belt.png'
3
+ import conveyorJoin from '../../assets/conveyor-join.png'
4
+ import conveyorJoinTrapezoid from '../../assets/conveyor-join-trapezoid.png'
5
+ import scanner from '../../assets/scanner.png'
6
+ import wheelSorter from '../../assets/wheel-sorter.png'
7
+
8
+ export default [
9
+ {
10
+ type: 'conveyor',
11
+ description: 'roller type conveyor',
12
+ group: 'warehouse',
13
+ icon: conveyor,
14
+ model: {
15
+ type: 'conveyor',
16
+ top: 350,
17
+ left: 100,
18
+ width: 500,
19
+ height: 100,
20
+ strokeStyle: '#999',
21
+ lineWidth: 1,
22
+ lineStyle: '#999',
23
+ value: 1,
24
+ rollWidth: 13
25
+ }
26
+ },
27
+ {
28
+ type: 'conveyor-belt',
29
+ description: 'belt type conveyor',
30
+ group: 'warehouse',
31
+ icon: conveyorBelt,
32
+ model: {
33
+ type: 'conveyor-belt',
34
+ top: 500,
35
+ left: 100,
36
+ width: 500,
37
+ height: 100,
38
+ strokeStyle: '#999',
39
+ lineWidth: 1,
40
+ lineStyle: '#999',
41
+ value: 1,
42
+ conveyorType: 1,
43
+ rollWidth: 13
44
+ }
45
+ },
46
+ {
47
+ type: 'conveyor-join',
48
+ description: 'join shaped conveyor',
49
+ group: 'warehouse',
50
+ icon: conveyorJoin,
51
+ model: {
52
+ type: 'conveyor-join',
53
+ cx: 100,
54
+ cy: 150,
55
+ rx: 100,
56
+ ry: 100,
57
+ startAngle: -Math.PI / 4,
58
+ endAngle: Math.PI / 4,
59
+ ratio: 34,
60
+ lineWidth: 1,
61
+ strokeStyle: 'black',
62
+ value: 2,
63
+ rollWidth: 12
64
+ }
65
+ },
66
+ {
67
+ type: 'scanner',
68
+ description: 'box scanner',
69
+ group: 'warehouse',
70
+ icon: scanner,
71
+ model: {
72
+ type: 'scanner',
73
+ top: 100,
74
+ left: 450,
75
+ width: 150,
76
+ height: 100,
77
+ lineWidth: 1,
78
+ strokeStyle: '#999',
79
+ fillStyle: 'transparent',
80
+ value: 2,
81
+ rollWidth: 3
82
+ }
83
+ },
84
+ {
85
+ type: 'conveyor-join-trapezoid',
86
+ description: 'conveyor join trapezoid',
87
+ group: 'warehouse',
88
+ icon: conveyorJoinTrapezoid,
89
+ model: {
90
+ type: 'conveyor-join-trapezoid',
91
+ lineWidth: 1,
92
+ path: [
93
+ { x: 50, y: 150 },
94
+ { x: 150, y: 150 },
95
+ { x: 150, y: 250 },
96
+ { x: 100, y: 300 },
97
+ { x: 50, y: 250 }
98
+ ],
99
+ strokeStyle: '#999',
100
+ fillStyle: 'transparent',
101
+ value: 3,
102
+ rollWidth: 10
103
+ }
104
+ },
105
+ {
106
+ type: 'wheel-sorter',
107
+ description: 'wheel sorter',
108
+ group: 'warehouse',
109
+ icon: wheelSorter,
110
+ model: {
111
+ type: 'wheel-sorter',
112
+ top: 50,
113
+ left: 200,
114
+ width: 200,
115
+ height: 200,
116
+ strokeStyle: '#999',
117
+ fillStyle: 'transparent',
118
+ lineWidth: 2,
119
+ value: 1,
120
+ tilt: 1
121
+ }
122
+ }
123
+ ]
@@ -0,0 +1,63 @@
1
+ import { Component, RectPath, Shape } from '@hatiolab/things-scene'
2
+
3
+ /*
4
+ * Copyright © HatioLab Inc. All rights reserved.
5
+ */
6
+ import MixinWheelSorter from './mixin-wheel-sorter'
7
+
8
+ const NATURE = {
9
+ mutable: false,
10
+ resizable: true,
11
+ rotatable: true,
12
+ properties: [
13
+ {
14
+ type: 'number',
15
+ label: 'tilt',
16
+ name: 'tilt'
17
+ },
18
+ {
19
+ type: 'number',
20
+ label: 'wheel-size',
21
+ name: 'wheelSize'
22
+ },
23
+ {
24
+ type: 'number',
25
+ label: 'value',
26
+ name: 'value'
27
+ },
28
+ {
29
+ type: 'checkbox',
30
+ label: 'animation',
31
+ name: 'animated'
32
+ }
33
+ ],
34
+ help: 'scene/component/wheel-sorter'
35
+ }
36
+
37
+ export default class WheelSorter extends MixinWheelSorter(RectPath(Shape)) {
38
+ get nature() {
39
+ return NATURE
40
+ }
41
+
42
+ render(ctx: CanvasRenderingContext2D) {
43
+ var { width, height, left, top, animated } = this.model
44
+
45
+ animated && this.animOnState()
46
+
47
+ ctx.beginPath()
48
+ ctx.rect(left, top, width, height)
49
+
50
+ ctx.clip() // bound를 벗어난 영역에도 그려지는 것을 예방.
51
+ }
52
+
53
+ postrender(ctx: CanvasRenderingContext2D) {
54
+ super.postrender(ctx)
55
+ this._draw_pattern(ctx)
56
+ }
57
+
58
+ is3dish() {
59
+ return false
60
+ }
61
+ }
62
+
63
+ Component.register('wheel-sorter', WheelSorter as any)