@avs/go 0.14.71999 → 0.14.72008
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/README.md +1 -1
- package/dist/avs-element-mixin.d.ts +28 -0
- package/dist/avs-element-mixin.d.ts.map +1 -0
- package/dist/avs-element-mixin.js +108 -0
- package/dist/avs-go-dataviz.d.ts +457 -0
- package/dist/avs-go-dataviz.d.ts.map +1 -0
- package/dist/avs-go-dataviz.js +2090 -0
- package/dist/avs-go-dynamic-html.d.ts +52 -0
- package/dist/avs-go-dynamic-html.d.ts.map +1 -0
- package/dist/avs-go-dynamic-html.js +124 -0
- package/dist/avs-go-info.d.ts +57 -0
- package/dist/avs-go-info.d.ts.map +1 -0
- package/dist/avs-go-info.js +127 -0
- package/dist/avs-go.min.js +211 -160
- package/dist/avs-renderer.d.ts +37 -0
- package/dist/avs-renderer.d.ts.map +1 -0
- package/dist/avs-renderer.js +33 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +20 -0
- package/dist/icons.d.ts +28 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +27 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/types.d.ts +142 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +36 -0
- package/package.json +4 -3
- package/rollup.config.js +17 -7
- package/src/avs-element-mixin.ts +126 -0
- package/src/{avs-go-dataviz.js → avs-go-dataviz.ts} +549 -710
- package/src/{avs-go-dynamic-html.js → avs-go-dynamic-html.ts} +37 -50
- package/src/{avs-go-info.js → avs-go-info.ts} +36 -47
- package/src/{avs-renderer.js → avs-renderer.ts} +10 -2
- package/src/{constants.js → constants.ts} +1 -1
- package/src/icons.ts +29 -0
- package/src/{avs-go.js → index.ts} +3 -3
- package/src/types.ts +160 -0
- package/tsconfig.json +16 -0
- package/src/avs-element-base.js +0 -119
- package/src/logo.js +0 -29
|
@@ -0,0 +1,2090 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2018 Advanced Visual Systems Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* This product includes software developed at
|
|
18
|
+
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
19
|
+
*/
|
|
20
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
21
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
23
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
24
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
|
+
};
|
|
26
|
+
import { AvsElementMixin } from './avs-element-mixin.js';
|
|
27
|
+
import { LitElement, html } from 'lit';
|
|
28
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
29
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
30
|
+
import { AvsRenderer } from './avs-renderer.js';
|
|
31
|
+
import { Viewer, TransformInteractor, PanInteractor, ZoomRectangleInteractor, PickDepthEnum, Animator } from '../lib/avs-three.module.min.js';
|
|
32
|
+
import { AVS, PLAY, CAMERA, TIMELAPSE, HOME, DELETE, COPY, LINK } from './icons.js';
|
|
33
|
+
import { Euler, Vector3, Quaternion } from 'three';
|
|
34
|
+
import { Renderer } from './types.js';
|
|
35
|
+
const ro = new ResizeObserver((entries, observer) => {
|
|
36
|
+
entries.forEach((entry) => {
|
|
37
|
+
const target = entry.target;
|
|
38
|
+
target._onResize(entry.contentRect);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* `avs-go-dataviz` is a Lit element which requests a data visualization
|
|
43
|
+
* from either the `sceneName` class on the AVS/Go server application running at `url`,
|
|
44
|
+
* or from a JSON file at `url` when `urlLoadJsonFile` is set.
|
|
45
|
+
*
|
|
46
|
+
* The request occurs upon:
|
|
47
|
+
* * An explicit call to `updateViewer()`
|
|
48
|
+
* * A change in `renderer`
|
|
49
|
+
* * Additionally if `manualUpdate` is false:
|
|
50
|
+
* * * Initialization of this element has completed
|
|
51
|
+
* * * This element is resized outside of the `resizeThresold` percentage
|
|
52
|
+
*
|
|
53
|
+
* @customElement
|
|
54
|
+
* @lit
|
|
55
|
+
* @applysMixin AvsElementMixin
|
|
56
|
+
*/
|
|
57
|
+
let AvsGoDataViz = class AvsGoDataViz extends AvsElementMixin(LitElement) {
|
|
58
|
+
render() {
|
|
59
|
+
return html `
|
|
60
|
+
<style>
|
|
61
|
+
:host {
|
|
62
|
+
display:block;
|
|
63
|
+
width:100%;
|
|
64
|
+
height:100%;
|
|
65
|
+
overflow:hidden;
|
|
66
|
+
position:relative;
|
|
67
|
+
letter-spacing:normal;
|
|
68
|
+
word-spacing:normal;
|
|
69
|
+
line-height:normal;
|
|
70
|
+
text-indent:0;
|
|
71
|
+
text-transform:none;
|
|
72
|
+
direction:ltr;
|
|
73
|
+
}
|
|
74
|
+
#dataVizDiv {
|
|
75
|
+
position:relative;
|
|
76
|
+
width:100%;
|
|
77
|
+
height:100%;
|
|
78
|
+
}
|
|
79
|
+
#motionCapture {
|
|
80
|
+
display: none;
|
|
81
|
+
position:absolute;
|
|
82
|
+
top: 8px;
|
|
83
|
+
left: 8px;
|
|
84
|
+
padding: 8px;
|
|
85
|
+
background-color: rgba(128, 128, 128, 0.8);
|
|
86
|
+
font-size: 10pt;
|
|
87
|
+
border-radius: 8px;
|
|
88
|
+
background:var(--avs-motion-capture-background, rgba(80,80,80,0.75));
|
|
89
|
+
color:var(--avs-motion-capture-color, #ffffff);
|
|
90
|
+
font-family:var(--avs-motion-capture-font-family);
|
|
91
|
+
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
|
|
92
|
+
user-select: none;
|
|
93
|
+
}
|
|
94
|
+
#motionCaptureTitle {
|
|
95
|
+
margin-bottom: 4px;
|
|
96
|
+
font-weight: 700;
|
|
97
|
+
}
|
|
98
|
+
.btn {
|
|
99
|
+
padding: 4px;
|
|
100
|
+
border-radius: 4px;
|
|
101
|
+
margin: 2px;
|
|
102
|
+
background:var(--avs-motion-capture-control-background, white);
|
|
103
|
+
color:var(--avs-motion-capture-control-color, black);
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
box-shadow: 0 2px 2px #00000024,0 3px 1px -2px #0000001f,0 1px 5px #0003;
|
|
107
|
+
}
|
|
108
|
+
a.btn {
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
}
|
|
111
|
+
.btn.disabled {
|
|
112
|
+
cursor: default;
|
|
113
|
+
pointer-events: none;
|
|
114
|
+
box-shadow: none;
|
|
115
|
+
background-color: darkgrey;
|
|
116
|
+
color: grey;
|
|
117
|
+
}
|
|
118
|
+
#motionCaptureSnapshotIcon, #motionCaptureDelayIcon {
|
|
119
|
+
height: 24px;
|
|
120
|
+
}
|
|
121
|
+
#motionCaptureSnapshotLabel, #motionCaptureDelayLabel {
|
|
122
|
+
margin-left: 4px;
|
|
123
|
+
height: 14px;
|
|
124
|
+
}
|
|
125
|
+
#motionCaptureDelayWheel {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
margin: 0 4px;
|
|
129
|
+
height: 24px;
|
|
130
|
+
gap: 2px;
|
|
131
|
+
}
|
|
132
|
+
#motionCaptureDelayIncrease, #motionCaptureDelayDecrease {
|
|
133
|
+
height: 8px;
|
|
134
|
+
text-align: center;
|
|
135
|
+
font-weight: 700;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
138
|
+
#motionCaptureReset, #motionCaptureCopyData {
|
|
139
|
+
margin-left: 12px;
|
|
140
|
+
}
|
|
141
|
+
#sceneImage {
|
|
142
|
+
width:100%;
|
|
143
|
+
height:100%;
|
|
144
|
+
position:absolute;
|
|
145
|
+
outline:none;
|
|
146
|
+
}
|
|
147
|
+
#rectCanvas {
|
|
148
|
+
position:absolute;
|
|
149
|
+
top:0px;
|
|
150
|
+
left:0px;
|
|
151
|
+
}
|
|
152
|
+
#zoomOverlay {
|
|
153
|
+
position:absolute;
|
|
154
|
+
opacity:0;
|
|
155
|
+
transition:opacity ease 0.3s;
|
|
156
|
+
pointer-events:none;
|
|
157
|
+
background:var(--avs-zoom-overlay-background, rgba(80,80,80,0.75));
|
|
158
|
+
color:var(--avs-zoom-overlay-color, #ffffff);
|
|
159
|
+
border-radius:5px;
|
|
160
|
+
padding:5px;
|
|
161
|
+
transform:translate(-50%, -100%);
|
|
162
|
+
font-size:var(--avs-zoom-overlay-font-size, 10pt);
|
|
163
|
+
font-family:var(--avs-zoom-overlay-font-family);
|
|
164
|
+
font-weight:var(--avs-zoom-overlay-font-weight, bold);
|
|
165
|
+
font-style:var(--avs-zoom-overlay-font-style);
|
|
166
|
+
}
|
|
167
|
+
#tooltip, #motionCaptureTooltip, #motionCaptureAlert {
|
|
168
|
+
position:absolute;
|
|
169
|
+
opacity:0;
|
|
170
|
+
transition:opacity ease 0.3s;
|
|
171
|
+
pointer-events:none;
|
|
172
|
+
padding:5px;
|
|
173
|
+
border-radius:5px;
|
|
174
|
+
background:var(--avs-tooltip-background, rgb(80,80,80));
|
|
175
|
+
color:var(--avs-tooltip-color, #ffffff);
|
|
176
|
+
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
|
|
177
|
+
font-size:var(--avs-tooltip-font-size, 10pt);
|
|
178
|
+
font-family:var(--avs-tooltip-font-family);
|
|
179
|
+
font-weight:var(--avs-tooltip-font-weight);
|
|
180
|
+
font-style:var(--avs-tooltip-font-style);
|
|
181
|
+
}
|
|
182
|
+
#motionCaptureAlert {
|
|
183
|
+
left: 50%;
|
|
184
|
+
top: 50%;
|
|
185
|
+
transform: translate(-50%, -50%);
|
|
186
|
+
}
|
|
187
|
+
#spinnerDiv {
|
|
188
|
+
position:absolute;
|
|
189
|
+
left:var(--avs-spinner-left, 50%);
|
|
190
|
+
top:var(--avs-spinner-top, 50%);
|
|
191
|
+
transform:var(--avs-spinner-transform, translate(-50%,-50%));
|
|
192
|
+
}
|
|
193
|
+
#spinner {
|
|
194
|
+
display:none;
|
|
195
|
+
}
|
|
196
|
+
.spin {
|
|
197
|
+
-webkit-animation:spin 2s ease-in-out infinite;
|
|
198
|
+
-moz-animation:spin 2s ease-in-out infinite;
|
|
199
|
+
animation:spin 2s ease-in-out infinite;
|
|
200
|
+
}
|
|
201
|
+
.spinnerBackground {
|
|
202
|
+
fill:var(--avs-spinner-background-color, rgb(0,0,0,0));
|
|
203
|
+
stroke-width:0.0160303
|
|
204
|
+
}
|
|
205
|
+
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
|
|
206
|
+
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
|
|
207
|
+
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
|
|
208
|
+
</style>
|
|
209
|
+
<div id="dataVizDiv"></div>
|
|
210
|
+
<div id="motionCapture">
|
|
211
|
+
<div style="display: flex; justify-content: center" id="motionCaptureTitle">Motion Capture</div>
|
|
212
|
+
<div>
|
|
213
|
+
<a class="btn disabled" id="motionCapturePlay" data-tooltip="Play motion capture" @click="${this.runAnimation}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${unsafeSVG(PLAY)}</a>
|
|
214
|
+
<a class="btn" id="motionCaptureSnapshot" data-tooltip="Take snapshot" @click="${this._handleMotionCaptureSnapshot}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">
|
|
215
|
+
<div id="motionCaptureSnapshotIcon">${unsafeSVG(CAMERA)}</div>
|
|
216
|
+
<div id="motionCaptureSnapshotLabel">0</div>
|
|
217
|
+
</a>
|
|
218
|
+
<div class="btn disabled" id="motionCaptureDelay" data-tooltip="Frame delay (seconds)" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">
|
|
219
|
+
<div id="motionCaptureDelayIcon">${unsafeSVG(TIMELAPSE)}</div>
|
|
220
|
+
<div id="motionCaptureDelayLabel">0</div>
|
|
221
|
+
<div id="motionCaptureDelayWheel">
|
|
222
|
+
<a id="motionCaptureDelayIncrease" @click="${this._handleMotionCaptureDelayIncrease}">+</a>
|
|
223
|
+
<a id="motionCaptureDelayDecrease" @click="${this._handleMotionCaptureDelayDecrease}">-</a>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
<a class="btn" id="motionCaptureReset" data-tooltip="Reset transform" @click="${this.resetTransform}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${unsafeSVG(HOME)}</a>
|
|
227
|
+
<a class="btn disabled" id="motionCaptureClear" data-tooltip="Clear motion capture frames" @click="${this._handleMotionCaptureClear}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${unsafeSVG(DELETE)}</a>
|
|
228
|
+
<a class="btn disabled" id="motionCaptureCopyData" data-tooltip="Copy motion capture data to clipboard" @click="${this._handleMotionCaptureCopyData}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${unsafeSVG(COPY)}</a>
|
|
229
|
+
<a class="btn disabled" id="motionCaptureCopyUrl" data-tooltip="Copy motion capture URL to clipboard" @click="${this._handleMotionCaptureCopyUrl}" @pointermove="${this._handlePointerEnterMotionCaptureControl}" @pointerout="${this._handlePointerLeaveMotionCaptureControl}">${unsafeSVG(LINK)}</a>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
<div id="motionCaptureTooltip"></div>
|
|
233
|
+
<div id="motionCaptureAlert"></div>
|
|
234
|
+
<div id="zoomOverlay"></div>
|
|
235
|
+
<div id="spinnerDiv">
|
|
236
|
+
<div id="spinner"></div>
|
|
237
|
+
</div>
|
|
238
|
+
<div id="tooltip"></div>
|
|
239
|
+
`;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Default line style and color
|
|
243
|
+
*/
|
|
244
|
+
_rectangleStyle() {
|
|
245
|
+
this.rectCtx.setLineDash([3]);
|
|
246
|
+
this.rectCtx.strokeStyle = "#ff0000";
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Assemble the model from our properties to send to the server.
|
|
250
|
+
*/
|
|
251
|
+
_assembleModel(fullReset) {
|
|
252
|
+
if (!this.sceneName) {
|
|
253
|
+
this._dispatchErrorEvent("'scene-name' property must be set to the name of the scene registered in the library map on the AVS/Go server.");
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
if (!this.width || !this.height) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
// Scene Properties
|
|
260
|
+
const model = {
|
|
261
|
+
sceneProperties: {
|
|
262
|
+
name: this.sceneName
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
if (this.sceneUserProperties) {
|
|
266
|
+
let sceneUserProperties;
|
|
267
|
+
try {
|
|
268
|
+
sceneUserProperties = JSON.parse(this.sceneUserProperties);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
this._dispatchErrorEvent("Can't parse 'scene-user-properties'. " + error.message);
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
model.sceneProperties.userProperties = sceneUserProperties;
|
|
275
|
+
}
|
|
276
|
+
// Renderer Properties
|
|
277
|
+
const rendererProperties = {
|
|
278
|
+
width: this.width,
|
|
279
|
+
height: this.height,
|
|
280
|
+
name: this.rendererName,
|
|
281
|
+
type: this.renderer
|
|
282
|
+
};
|
|
283
|
+
if (this.rendererUserProperties) {
|
|
284
|
+
let rendererUserProperties;
|
|
285
|
+
try {
|
|
286
|
+
rendererUserProperties = JSON.parse(this.rendererUserProperties);
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
this._dispatchErrorEvent("Can't parse 'renderer-user-properties'. " + error.message);
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
rendererProperties.userProperties = rendererUserProperties;
|
|
293
|
+
}
|
|
294
|
+
model.rendererProperties = rendererProperties;
|
|
295
|
+
// Transform Properties
|
|
296
|
+
if (this.transformInteractor) {
|
|
297
|
+
// Update the local transform matrix from the transform interactor, we may have transformed since the last request
|
|
298
|
+
this.transformMatrix = this.transformInteractor.object.matrix.elements.slice();
|
|
299
|
+
// this.transformClientOnly = this.transformInteractor.clientOnly;
|
|
300
|
+
}
|
|
301
|
+
if (this.transformMatrix && !this.transformClientOnly) {
|
|
302
|
+
rendererProperties.transformMatrix = this.transformMatrix;
|
|
303
|
+
}
|
|
304
|
+
if (fullReset) {
|
|
305
|
+
if (this.transformClientOnly && this.transformInteractor) {
|
|
306
|
+
this.transformInteractor.fullReset = fullReset;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
rendererProperties.fullReset = true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// PanInteractor
|
|
313
|
+
if (this.panEnable) {
|
|
314
|
+
rendererProperties.panProperties = {
|
|
315
|
+
widthZoomLevel: Math.min(this.panWidthZoomLevel, this.panMaximumZoomLevel),
|
|
316
|
+
heightZoomLevel: Math.min(this.panHeightZoomLevel, this.panMaximumZoomLevel)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
// Base theme to use from themeName property
|
|
320
|
+
rendererProperties.themeName = this.themeName;
|
|
321
|
+
var style = window.getComputedStyle(this, null);
|
|
322
|
+
// Theme Properties from page CSS
|
|
323
|
+
var cssBackgroundColor = style.getPropertyValue("background-color").trim();
|
|
324
|
+
var cssColor = style.getPropertyValue("color").trim();
|
|
325
|
+
var cssFontFamily = style.getPropertyValue("font-family").trim().replace(/['"]+/g, '');
|
|
326
|
+
rendererProperties.cssProperties = {
|
|
327
|
+
sceneBackgroundType: "Solid",
|
|
328
|
+
sceneBackgroundColor: cssBackgroundColor,
|
|
329
|
+
sceneLineColor: cssColor,
|
|
330
|
+
sceneTextColor: cssColor,
|
|
331
|
+
sceneFontFamily: cssFontFamily,
|
|
332
|
+
sceneSurfaceColor: cssColor
|
|
333
|
+
};
|
|
334
|
+
// Theme Properties from custom CSS
|
|
335
|
+
this._applyCustomCssProperties(rendererProperties.cssProperties, style, {
|
|
336
|
+
// Scene
|
|
337
|
+
"sceneBackgroundType": "--avs-scene-background-type",
|
|
338
|
+
"sceneBackgroundColor": "--avs-scene-background-color",
|
|
339
|
+
"sceneBackgroundStartColor": "--avs-scene-background-start-color",
|
|
340
|
+
"sceneBackgroundEndColor": "--avs-scene-background-end-color",
|
|
341
|
+
"sceneBackgroundGradientStyle": "--avs-scene-background-gradient-style",
|
|
342
|
+
"sceneBackgroundGradientInterpolation": "--avs-scene-background-gradient-interpolation",
|
|
343
|
+
"sceneBackgroundGradientColorRepeat": "--avs-scene-background-gradient-color-repeat",
|
|
344
|
+
"sceneHighlightColor": "--avs-scene-highlight-color",
|
|
345
|
+
"sceneSurfaceColor": "--avs-scene-surface-color",
|
|
346
|
+
"scenePointColor": "--avs-scene-point-color",
|
|
347
|
+
"sceneLineColor": "--avs-scene-line-color",
|
|
348
|
+
"sceneLineWidth": "--avs-scene-line-width",
|
|
349
|
+
"sceneTextColor": "--avs-scene-text-color",
|
|
350
|
+
"sceneTextRotation": "--avs-scene-text-rotation",
|
|
351
|
+
"sceneFontFamily": "--avs-scene-font-family",
|
|
352
|
+
"sceneFontStyle": "--avs-scene-font-style",
|
|
353
|
+
"sceneFontWeight": "--avs-scene-font-weight",
|
|
354
|
+
"sceneFontSize": "--avs-scene-font-size",
|
|
355
|
+
// Scene title
|
|
356
|
+
"sceneTitleTextColor": "--avs-scene-title-text-color",
|
|
357
|
+
"sceneTitleTextRotation": "--avs-scene-title-text-rotation",
|
|
358
|
+
"sceneTitleFontFamily": "--avs-scene-title-font-family",
|
|
359
|
+
"sceneTitleFontStyle": "--avs-scene-title-font-style",
|
|
360
|
+
"sceneTitleFontWeight": "--avs-scene-title-font-weight",
|
|
361
|
+
"sceneTitleFontSize": "--avs-scene-title-font-size",
|
|
362
|
+
// Chart
|
|
363
|
+
"chartBackgroundType": "--avs-chart-background-type",
|
|
364
|
+
"chartBackgroundColor": "--avs-chart-background-color",
|
|
365
|
+
"chartBackgroundStartColor": "--avs-chart-background-start-color",
|
|
366
|
+
"chartBackgroundEndColor": "--avs-chart-background-end-color",
|
|
367
|
+
"chartBackgroundGradientStyle": "--avs-chart-background-gradient-style",
|
|
368
|
+
"chartBackgroundGradientInterpolation": "--avs-chart-background-gradient-interpolation",
|
|
369
|
+
"chartBackgroundGradientColorRepeat": "--avs-chart-background-gradient-color-repeat",
|
|
370
|
+
"chartHighlightColor": "--avs-chart-highlight-color",
|
|
371
|
+
"chartSurfaceColor": "--avs-chart-surface-color",
|
|
372
|
+
"chartPointColor": "--avs-chart-point-color",
|
|
373
|
+
"chartLineColor": "--avs-chart-line-color",
|
|
374
|
+
"chartLineWidth": "--avs-chart-line-width",
|
|
375
|
+
"chartLinePattern": "--avs-chart-line-pattern",
|
|
376
|
+
"chartTextColor": "--avs-chart-text-color",
|
|
377
|
+
"chartTextRotation": "--avs-chart-text-rotation",
|
|
378
|
+
"chartFontFamily": "--avs-chart-font-family",
|
|
379
|
+
"chartFontStyle": "--avs-chart-font-style",
|
|
380
|
+
"chartFontWeight": "--avs-chart-font-weight",
|
|
381
|
+
"chartFontSize": "--avs-chart-font-size",
|
|
382
|
+
// Chart title
|
|
383
|
+
"chartTitleTextColor": "--avs-chart-title-text-color",
|
|
384
|
+
"chartTitleTextRotation": "--avs-chart-title-text-rotation",
|
|
385
|
+
"chartTitleFontFamily": "--avs-chart-title-font-family",
|
|
386
|
+
"chartTitleFontStyle": "--avs-chart-title-font-style",
|
|
387
|
+
"chartTitleFontWeight": "--avs-chart-title-font-weight",
|
|
388
|
+
"chartTitleFontSize": "--avs-chart-title-font-size",
|
|
389
|
+
// Axis
|
|
390
|
+
"axisLineColor": "--avs-axis-line-color",
|
|
391
|
+
"axisLineWidth": "--avs-axis-line-width",
|
|
392
|
+
"axisTextColor": "--avs-axis-text-color",
|
|
393
|
+
"axisTextRotation": "--avs-axis-text-rotation",
|
|
394
|
+
"axisFontFamily": "--avs-axis-font-family",
|
|
395
|
+
"axisFontStyle": "--avs-axis-font-style",
|
|
396
|
+
"axisFontWeight": "--avs-axis-font-weight",
|
|
397
|
+
"axisFontSize": "--avs-axis-font-size",
|
|
398
|
+
// Axis axle
|
|
399
|
+
"axisAxleColor": "--avs-axis-axle-color",
|
|
400
|
+
"axisAxleWidth": "--avs-axis-axle-width",
|
|
401
|
+
// Axis major tick marks
|
|
402
|
+
"axisMajorTickMarkColor": "--avs-axis-major-tick-mark-color",
|
|
403
|
+
"axisMajorTickMarkWidth": "--avs-axis-major-tick-mark-width",
|
|
404
|
+
// Axis major tick lines
|
|
405
|
+
"axisMajorTickLineColor": "--avs-axis-major-tick-line-color",
|
|
406
|
+
"axisMajorTickLineWidth": "--avs-axis-major-tick-line-width",
|
|
407
|
+
"axisMajorTickLineStyle": "--avs-axis-major-tick-line-style",
|
|
408
|
+
// Axis major unlabeled tick marks
|
|
409
|
+
"axisMajorUnlabeledTickMarkColor": "--avs-axis-major-unlabeled-tick-mark-color",
|
|
410
|
+
"axisMajorUnlabeledTickMarkWidth": "--avs-axis-major-unlabeled-tick-mark-width",
|
|
411
|
+
// Axis major unlabeled tick lines
|
|
412
|
+
"axisMajorUnlabeledTickLineColor": "--avs-axis-major-unlabeled-tick-line-color",
|
|
413
|
+
"axisMajorUnlabeledTickLineWidth": "--avs-axis-major-unlabeled-tick-line-width",
|
|
414
|
+
"axisMajorUnlabeledTickLineStyle": "--avs-axis-major-unlabeled-tick-line-style",
|
|
415
|
+
// Axis minor tick marks
|
|
416
|
+
"axisMinorTickMarkColor": "--avs-axis-minor-tick-mark-color",
|
|
417
|
+
"axisMinorTickMarkWidth": "--avs-axis-minor-tick-mark-width",
|
|
418
|
+
// Axis minor tick lines
|
|
419
|
+
"axisMinorTickLineColor": "--avs-axis-minor-tick-line-color",
|
|
420
|
+
"axisMinorTickLineWidth": "--avs-axis-minor-tick-line-width",
|
|
421
|
+
"axisMinorTickLineStyle": "--avs-axis-minor-tick-line-style",
|
|
422
|
+
// Axis title
|
|
423
|
+
"axisTitleTextColor": "--avs-axis-title-text-color",
|
|
424
|
+
"axisTitleTextRotation": "--avs-axis-title-text-rotation",
|
|
425
|
+
"axisTitleFontFamily": "--avs-axis-title-font-family",
|
|
426
|
+
"axisTitleFontStyle": "--avs-axis-title-font-style",
|
|
427
|
+
"axisTitleFontWeight": "--avs-axis-title-font-weight",
|
|
428
|
+
"axisTitleFontSize": "--avs-axis-title-font-size",
|
|
429
|
+
// Axis unit
|
|
430
|
+
"axisUnitTextColor": "--avs-axis-unit-text-color",
|
|
431
|
+
"axisUnitTextRotation": "--avs-axis-unit-text-rotation",
|
|
432
|
+
"axisUnitFontFamily": "--avs-axis-unit-font-family",
|
|
433
|
+
"axisUnitFontStyle": "--avs-axis-unit-font-style",
|
|
434
|
+
"axisUnitFontWeight": "--avs-axis-unit-font-weight",
|
|
435
|
+
"axisUnitFontSize": "--avs-axis-unit-font-size",
|
|
436
|
+
// Axis labels
|
|
437
|
+
"axisLabelTextColor": "--avs-axis-label-text-color",
|
|
438
|
+
"axisLabelTextRotation": "--avs-axis-label-text-rotation",
|
|
439
|
+
"axisLabelFontFamily": "--avs-axis-label-font-family",
|
|
440
|
+
"axisLabelFontStyle": "--avs-axis-label-font-style",
|
|
441
|
+
"axisLabelFontWeight": "--avs-axis-label-font-weight",
|
|
442
|
+
"axisLabelFontSize": "--avs-axis-label-font-size",
|
|
443
|
+
// Legend
|
|
444
|
+
"legendBackgroundColor": "--avs-legend-background-color",
|
|
445
|
+
"legendTextColor": "--avs-legend-text-color",
|
|
446
|
+
"legendTextRotation": "--avs-legend-text-rotation",
|
|
447
|
+
"legendFontFamily": "--avs-legend-font-family",
|
|
448
|
+
"legendFontStyle": "--avs-legend-font-style",
|
|
449
|
+
"legendFontWeight": "--avs-legend-font-weight",
|
|
450
|
+
"legendFontSize": "--avs-legend-font-size",
|
|
451
|
+
"legendPointColor": "--avs-legend-point-color",
|
|
452
|
+
// Legend title
|
|
453
|
+
"legendTitleTextColor": "--avs-legend-title-text-color",
|
|
454
|
+
"legendTitleTextRotation": "--avs-legend-title-text-rotation",
|
|
455
|
+
"legendTitleFontFamily": "--avs-legend-title-font-family",
|
|
456
|
+
"legendTitleFontStyle": "--avs-legend-title-font-style",
|
|
457
|
+
"legendTitleFontWeight": "--avs-legend-title-font-weight",
|
|
458
|
+
"legendTitleFontSize": "--avs-legend-title-font-size"
|
|
459
|
+
});
|
|
460
|
+
// Data source properties
|
|
461
|
+
if (this.dataSourceName) {
|
|
462
|
+
model.dataSourceProperties = {
|
|
463
|
+
name: this.dataSourceName
|
|
464
|
+
};
|
|
465
|
+
if (this.dataSourceUserProperties) {
|
|
466
|
+
let dataSourceUserProperties;
|
|
467
|
+
try {
|
|
468
|
+
dataSourceUserProperties = JSON.parse(this.dataSourceUserProperties);
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
this._dispatchErrorEvent("Can't parse 'data-source-user-properties'. " + error.message);
|
|
472
|
+
return undefined;
|
|
473
|
+
}
|
|
474
|
+
model.dataSourceProperties.userProperties = dataSourceUserProperties;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
// Stream properties
|
|
478
|
+
if (this.threeViewer) {
|
|
479
|
+
if (this.streamEnable) {
|
|
480
|
+
rendererProperties.streamProperties = {
|
|
481
|
+
chunkSizeFirst: this.streamChunkSizeFirst,
|
|
482
|
+
chunkSize: this.streamChunkSize
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return model;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
*
|
|
490
|
+
*/
|
|
491
|
+
_applyCustomCssProperties(cssProperties, style, values) {
|
|
492
|
+
for (var key in values) {
|
|
493
|
+
if (values.hasOwnProperty(key)) {
|
|
494
|
+
var css = style.getPropertyValue(values[key]).trim();
|
|
495
|
+
if (css.length > 0) {
|
|
496
|
+
cssProperties[key] = css;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
*/
|
|
504
|
+
_onResize(contentRect) {
|
|
505
|
+
// Get the width & height provided by our container
|
|
506
|
+
this.width = Math.round(contentRect.width);
|
|
507
|
+
this.height = Math.round(contentRect.height);
|
|
508
|
+
if (this.rectCanvas) {
|
|
509
|
+
this.rectCanvas.width = this.width;
|
|
510
|
+
this.rectCanvas.height = this.height;
|
|
511
|
+
}
|
|
512
|
+
// Check if we need to acquire a new scene due to
|
|
513
|
+
// the size change and other properties
|
|
514
|
+
if (!this.urlLoadJsonFile &&
|
|
515
|
+
!this.manualUpdate &&
|
|
516
|
+
this.resizeThreshold > 0 &&
|
|
517
|
+
(!this.lowResizeWidth ||
|
|
518
|
+
this.width < this.lowResizeWidth ||
|
|
519
|
+
this.width > this.highResizeWidth ||
|
|
520
|
+
this.height < this.lowResizeHeight ||
|
|
521
|
+
this.height > this.highResizeHeight)) {
|
|
522
|
+
this._updateResizeLimits();
|
|
523
|
+
this.updateViewer();
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
if (this.threeViewer) {
|
|
527
|
+
this.threeViewer.render(true);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
_updateResizeLimits() {
|
|
532
|
+
this.lowResizeWidth = (100 - this.resizeThreshold) / 100 * this.width;
|
|
533
|
+
this.highResizeWidth = (100 + this.resizeThreshold) / 100 * this.width;
|
|
534
|
+
this.lowResizeHeight = (100 - this.resizeThreshold) / 100 * this.height;
|
|
535
|
+
this.highResizeHeight = (100 + this.resizeThreshold) / 100 * this.height;
|
|
536
|
+
}
|
|
537
|
+
showSpinner() {
|
|
538
|
+
var spinner = window.getComputedStyle(this, null).getPropertyValue("--avs-spinner").trim().replace(/['"]+/g, '');
|
|
539
|
+
if (spinner.length > 0) {
|
|
540
|
+
fetch(spinner)
|
|
541
|
+
.then((response) => {
|
|
542
|
+
if (response.ok) {
|
|
543
|
+
return response.text();
|
|
544
|
+
}
|
|
545
|
+
})
|
|
546
|
+
.then((html) => {
|
|
547
|
+
this.renderRoot.querySelector('#spinner').innerHTML = html;
|
|
548
|
+
})
|
|
549
|
+
.catch((error) => {
|
|
550
|
+
this.renderRoot.querySelector('#spinner').innerHTML = AVS;
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
this.renderRoot.querySelector('#spinner').innerHTML = AVS;
|
|
555
|
+
}
|
|
556
|
+
const spinnerEl = this.renderRoot.querySelector('#spinner');
|
|
557
|
+
spinnerEl.style.display = 'block';
|
|
558
|
+
}
|
|
559
|
+
hideSpinner() {
|
|
560
|
+
const spinnerEl = this.renderRoot.querySelector('#spinner');
|
|
561
|
+
spinnerEl.style.display = 'none';
|
|
562
|
+
}
|
|
563
|
+
startSpinner() {
|
|
564
|
+
this.renderRoot.querySelector('#spinner').className = 'spin';
|
|
565
|
+
}
|
|
566
|
+
stopSpinner() {
|
|
567
|
+
this.renderRoot.querySelector('#spinner').className = '';
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* At least one of the properties was changed.
|
|
571
|
+
*/
|
|
572
|
+
updated(changedProperties) {
|
|
573
|
+
if (!Object.values(Renderer)?.includes(this.renderer)) {
|
|
574
|
+
this._dispatchErrorEvent("'renderer' property must be 'IMAGE', 'SVG' or 'THREEJS'.");
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (changedProperties.has('renderer')) {
|
|
578
|
+
this._rendererChanged(this.renderer, changedProperties['renderer']);
|
|
579
|
+
}
|
|
580
|
+
if (changedProperties.has('transformEnable')) {
|
|
581
|
+
this._transformEnableChanged(this.transformEnable, changedProperties['transformEnable']);
|
|
582
|
+
}
|
|
583
|
+
if (changedProperties.has('transformClientOnly')) {
|
|
584
|
+
this._transformClientOnlyChanged(this.transformClientOnly, changedProperties['transformClientOnly']);
|
|
585
|
+
}
|
|
586
|
+
if (changedProperties.has('transformRotateDisable')) {
|
|
587
|
+
this._transformRotateDisableChanged(this.transformRotateDisable, changedProperties['transformRotateDisable']);
|
|
588
|
+
}
|
|
589
|
+
if (changedProperties.has('transformZoomDisable')) {
|
|
590
|
+
this._transformZoomDisableChanged(this.transformZoomDisable, changedProperties['transformZoomDisable']);
|
|
591
|
+
}
|
|
592
|
+
if (changedProperties.has('transformPanDisable')) {
|
|
593
|
+
this._transformPanDisableChanged(this.transformPanDisable, changedProperties['transformPanDisable']);
|
|
594
|
+
}
|
|
595
|
+
if (changedProperties.has('animatedGlyphsVisible')) {
|
|
596
|
+
this._animatedGlyphsVisibleChanged(this.animatedGlyphsVisible, changedProperties['animatedGlyphsVisible']);
|
|
597
|
+
}
|
|
598
|
+
if (changedProperties.has('animatedGlyphsEnable')) {
|
|
599
|
+
this._animatedGlyphsEnableChanged(this.animatedGlyphsEnable, changedProperties['animatedGlyphsEnable']);
|
|
600
|
+
}
|
|
601
|
+
if (changedProperties.has('transformTwistAngle') || changedProperties.has('transformTiltAngle') || changedProperties.has('transformScale')) {
|
|
602
|
+
this._transformValueChanged();
|
|
603
|
+
}
|
|
604
|
+
if (changedProperties.has('animatedGlyphsEnable')) {
|
|
605
|
+
this._animatedGlyphsEnableChanged(this.animatedGlyphsEnable, changedProperties['animatedGlyphsEnable']);
|
|
606
|
+
}
|
|
607
|
+
if (changedProperties.has('zoomRectangleEnable')) {
|
|
608
|
+
this._zoomRectangleEnableChanged(this.zoomRectangleEnable, changedProperties['zoomRectangleEnable']);
|
|
609
|
+
}
|
|
610
|
+
if (changedProperties.has('panEnable')) {
|
|
611
|
+
this._panEnableChanged(this.panEnable, changedProperties['panEnable']);
|
|
612
|
+
}
|
|
613
|
+
if (changedProperties.has('panZoomEnable')) {
|
|
614
|
+
this._panZoomEnableChanged(this.panZoomEnable, changedProperties['panZoomEnable']);
|
|
615
|
+
}
|
|
616
|
+
if (changedProperties.has('panWidthZoomLevel')) {
|
|
617
|
+
this._panWidthZoomLevelChanged(this.panWidthZoomLevel, changedProperties['panWidthZoomLevel']);
|
|
618
|
+
}
|
|
619
|
+
if (changedProperties.has('panHeightZoomLevel')) {
|
|
620
|
+
this._panHeightZoomLevelChanged(this.panHeightZoomLevel, changedProperties['panHeightZoomLevel']);
|
|
621
|
+
}
|
|
622
|
+
if (changedProperties.has('panMaximumZoomLevel')) {
|
|
623
|
+
this._panMaximumZoomLevelChanged(this.panMaximumZoomLevel, changedProperties['panMaximumZoomLevel']);
|
|
624
|
+
}
|
|
625
|
+
if (changedProperties.has('trackEnable')) {
|
|
626
|
+
this._trackEnableChanged(this.trackEnable, changedProperties['trackEnable']);
|
|
627
|
+
}
|
|
628
|
+
if (changedProperties.has('displayCanvas')) {
|
|
629
|
+
this._displayCanvasChanged(this.displayCanvas, changedProperties['displayCanvas']);
|
|
630
|
+
}
|
|
631
|
+
if (changedProperties.has('motionCaptureControlsEnable')) {
|
|
632
|
+
this._motionCaptureControlsEnableChanged(this.motionCaptureControlsEnable, changedProperties['motionCaptureControlsEnable']);
|
|
633
|
+
}
|
|
634
|
+
if (changedProperties.has('motionCapture')) {
|
|
635
|
+
this._motionCaptureValueChanged(this.motionCapture, changedProperties['motionCapture']);
|
|
636
|
+
}
|
|
637
|
+
if (!this.url) {
|
|
638
|
+
//this._dispatchErrorEvent(''url' property must point to an instance of AVS/Go server.');
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
let doUpdate = false;
|
|
642
|
+
if (this.manualUpdate) {
|
|
643
|
+
if (this.forceUpdate) {
|
|
644
|
+
doUpdate = true;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
if (this.forceUpdate ||
|
|
649
|
+
changedProperties.has('url') ||
|
|
650
|
+
changedProperties.has('renderer') ||
|
|
651
|
+
changedProperties.has('urlLoadJsonFile') ||
|
|
652
|
+
changedProperties.has('sceneName') ||
|
|
653
|
+
changedProperties.has('sceneUserProperties') ||
|
|
654
|
+
changedProperties.has('dataSourceName') ||
|
|
655
|
+
changedProperties.has('dataSourceUserProperties') ||
|
|
656
|
+
changedProperties.has('rendererName') ||
|
|
657
|
+
changedProperties.has('rendererUserProperties') ||
|
|
658
|
+
changedProperties.has('streamEnable') ||
|
|
659
|
+
(this.panEnable && changedProperties.has('panWidthZoomLevel')) ||
|
|
660
|
+
(this.panEnable && changedProperties.has('panHeightZoomLevel'))) {
|
|
661
|
+
doUpdate = true;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (doUpdate) {
|
|
665
|
+
this.forceUpdate = false;
|
|
666
|
+
// Send the model to the server
|
|
667
|
+
if (this.urlLoadJsonFile) {
|
|
668
|
+
this.chunkFile = 0;
|
|
669
|
+
this.showSpinner();
|
|
670
|
+
this.startSpinner();
|
|
671
|
+
this._httpRequest(this.url, this._handleHttpResponse.bind(this), this._handleHttpError.bind(this));
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
this.model = this._assembleModel( /*fullReset*/);
|
|
675
|
+
if (this.model) {
|
|
676
|
+
this.showSpinner();
|
|
677
|
+
this.startSpinner();
|
|
678
|
+
this._httpRequest(this.url, this._handleHttpResponse.bind(this), this._handleHttpError.bind(this), this.model);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* HTTP error handler.
|
|
685
|
+
*/
|
|
686
|
+
_handleHttpError() {
|
|
687
|
+
this.hideSpinner();
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
*
|
|
691
|
+
*/
|
|
692
|
+
updateViewer() {
|
|
693
|
+
this.forceUpdate = true;
|
|
694
|
+
this.requestUpdate();
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
*
|
|
698
|
+
*/
|
|
699
|
+
clear() {
|
|
700
|
+
if (this.threeViewer) {
|
|
701
|
+
this.threeViewer.clearGeometry();
|
|
702
|
+
this.threeViewer.render();
|
|
703
|
+
}
|
|
704
|
+
else if (this.renderer === 'SVG') {
|
|
705
|
+
var el = this.svgDiv;
|
|
706
|
+
while (el.firstChild)
|
|
707
|
+
el.removeChild(el.firstChild);
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
this.sceneImage.src = 'data:,';
|
|
711
|
+
}
|
|
712
|
+
this.showSpinner();
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* HTTP response handler.
|
|
716
|
+
* @param response Response parsed from HTTP or file.
|
|
717
|
+
*/
|
|
718
|
+
_handleHttpResponse(response) {
|
|
719
|
+
if (response) {
|
|
720
|
+
if (response.selectionInfo) {
|
|
721
|
+
this._dispatchPickEvents(response.selectionInfo);
|
|
722
|
+
}
|
|
723
|
+
if (response.sceneInfo) {
|
|
724
|
+
/**
|
|
725
|
+
* Scene info from the server.
|
|
726
|
+
* @event avs-scene-info
|
|
727
|
+
*/
|
|
728
|
+
this.dispatchEvent(new CustomEvent('avs-scene-info', { detail: response.sceneInfo }));
|
|
729
|
+
const motionCapture = this.renderRoot.querySelector('#motionCapture');
|
|
730
|
+
const zoomOverlay = this.renderRoot.querySelector('#zoomOverlay');
|
|
731
|
+
const tooltip = this.renderRoot.querySelector('#tooltip');
|
|
732
|
+
const motionCaptureTooltip = this.renderRoot.querySelector('#motionCaptureTooltip');
|
|
733
|
+
// Set animation controls, tooltip and zoom overlay style to reversed theme
|
|
734
|
+
if (response.sceneInfo.backgroundColor) {
|
|
735
|
+
var col = response.sceneInfo.backgroundColor.match(/[0-9.]+/gi);
|
|
736
|
+
var bgCol = this.getInheritedBackgroundCol(this).trim().match(/[0-9.]+/gi);
|
|
737
|
+
var blendedR = (Number(col[0]) * Number(col[3]));
|
|
738
|
+
var blendedG = (Number(col[1]) * Number(col[3]));
|
|
739
|
+
var blendedB = (Number(col[2]) * Number(col[3]));
|
|
740
|
+
if (Number(col[3]) == 0) {
|
|
741
|
+
// In case sceneInfo.backgroundColor is transparent, blend with inherited background color
|
|
742
|
+
blendedR += (bgCol[0] * (1 - Number(col[3])));
|
|
743
|
+
blendedG += (bgCol[1] * (1 - Number(col[3])));
|
|
744
|
+
blendedB += (bgCol[2] * (1 - Number(col[3])));
|
|
745
|
+
}
|
|
746
|
+
motionCapture.style.color = "var(--avs-motion-capture-color, rgb(" + blendedR + ", " + blendedG + ", " + blendedB + "))";
|
|
747
|
+
zoomOverlay.style.color = "var(--avs-zoom-overlay-color, rgb(" + blendedR + "," + blendedG + "," + blendedB + "))";
|
|
748
|
+
tooltip.style.color = "var(--avs-tooltip-color, rgb(" + blendedR + "," + blendedG + "," + blendedB + "))";
|
|
749
|
+
motionCaptureTooltip.style.color = "var(--avs-tooltip-color, rgb(" + blendedR + "," + blendedG + "," + blendedB + "))";
|
|
750
|
+
}
|
|
751
|
+
if (response.sceneInfo.color) {
|
|
752
|
+
var col = response.sceneInfo.color.match(/[0-9.]+/gi);
|
|
753
|
+
motionCapture.style.background = "var(--avs-motion-capture-background, rgba(" + col[0] + "," + col[1] + "," + col[2] + ",0.75))";
|
|
754
|
+
zoomOverlay.style.background = "var(--avs-zoom-overlay-background, rgba(" + col[0] + "," + col[1] + "," + col[2] + ",0.75))";
|
|
755
|
+
tooltip.style.background = "var(--avs-tooltip-background, rgb(" + col[0] + "," + col[1] + "," + col[2] + "))";
|
|
756
|
+
motionCaptureTooltip.style.background = "var(--avs-tooltip-background, rgb(" + col[0] + "," + col[1] + "," + col[2] + "))";
|
|
757
|
+
}
|
|
758
|
+
if (response.sceneInfo.fontFamily) {
|
|
759
|
+
motionCapture.style.fontFamily = "var(--avs-motion-capture-font-family, " + response.sceneInfo.fontFamily + ")";
|
|
760
|
+
zoomOverlay.style.fontFamily = "var(--avs-zoom-overlay-font-family, " + response.sceneInfo.fontFamily + ")";
|
|
761
|
+
tooltip.style.fontFamily = "var(--avs-tooltip-font-family, " + response.sceneInfo.fontFamily + ")";
|
|
762
|
+
motionCaptureTooltip.style.fontFamily = "var(--avs-tooltip-font-family, " + response.sceneInfo.fontFamily + ")";
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
if (response.image) {
|
|
766
|
+
this.sceneImage.src = response.image;
|
|
767
|
+
if (response.imagemap) {
|
|
768
|
+
this.sceneImageMap.innerHTML = decodeURIComponent(response.imagemap.replace(/\+/g, '%20'));
|
|
769
|
+
this.imageMapData = Array.from(this.sceneImageMap.querySelectorAll('area')).map(area => {
|
|
770
|
+
return {
|
|
771
|
+
shape: area.getAttribute('shape'),
|
|
772
|
+
coords: area.getAttribute('coords').split(',').map(Number),
|
|
773
|
+
seriesIndex: area.getAttribute('series-index'),
|
|
774
|
+
itemIndex: area.getAttribute('item-index'),
|
|
775
|
+
componentInfo: area.getAttribute('component-info')
|
|
776
|
+
};
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
else {
|
|
780
|
+
this.sceneImageMap.innerHTML = "";
|
|
781
|
+
this.imageMapData = undefined;
|
|
782
|
+
}
|
|
783
|
+
if (!this.urlLoadJsonFile) {
|
|
784
|
+
this._dispatchSceneData(response);
|
|
785
|
+
}
|
|
786
|
+
this._handleLoadComplete();
|
|
787
|
+
}
|
|
788
|
+
else if (response.svg) {
|
|
789
|
+
this.svgDiv.innerHTML = decodeURIComponent(response.svg.replace(/\+/g, '%20'));
|
|
790
|
+
if (!this.urlLoadJsonFile) {
|
|
791
|
+
this._dispatchSceneData(response);
|
|
792
|
+
}
|
|
793
|
+
this._handleLoadComplete();
|
|
794
|
+
}
|
|
795
|
+
else if (response.threejs) {
|
|
796
|
+
if (!this.urlLoadJsonFile) {
|
|
797
|
+
this._dispatchSceneData(response);
|
|
798
|
+
}
|
|
799
|
+
if (response.threejs.chunkId) {
|
|
800
|
+
this.threeViewer.loadGeometryAsEvents(response.threejs, this._handleLoadComplete.bind(this));
|
|
801
|
+
if (response.threejs.moreChunks) {
|
|
802
|
+
if (this.urlLoadJsonFile) {
|
|
803
|
+
// Load the next chunk file
|
|
804
|
+
this.chunkFile++;
|
|
805
|
+
const urlBase = this.url.substring(0, this.url.lastIndexOf('.')) || this.url;
|
|
806
|
+
const ext = this.url.split('.').pop();
|
|
807
|
+
this._httpRequest(urlBase + '-' + this.chunkFile + '.' + ext, this._handleHttpResponse.bind(this), this._handleHttpError.bind(this));
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
// Get the next chunk from the server
|
|
811
|
+
this.model.rendererProperties.streamProperties.chunkId = response.threejs.chunkId;
|
|
812
|
+
this._httpRequest(this.url, this._handleHttpResponse.bind(this), this._handleHttpError.bind(this), this.model);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
else {
|
|
817
|
+
this.threeViewer.loadGeometryAsJson(response.threejs, this._handleLoadComplete.bind(this));
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
this._dispatchErrorEvent("No image, SVG, or ThreeJS found in response.");
|
|
822
|
+
this._handleLoadComplete();
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
getInheritedBackgroundCol(el) {
|
|
827
|
+
var defaultStyle = this.getDefaultBackground();
|
|
828
|
+
var bgCol = window.getComputedStyle(el).backgroundColor;
|
|
829
|
+
if (bgCol != defaultStyle) {
|
|
830
|
+
return bgCol;
|
|
831
|
+
}
|
|
832
|
+
if (!el.parentElement) {
|
|
833
|
+
return defaultStyle;
|
|
834
|
+
}
|
|
835
|
+
return this.getInheritedBackgroundCol(el.parentElement);
|
|
836
|
+
}
|
|
837
|
+
getDefaultBackground() {
|
|
838
|
+
// have to add to the document in order to use getComputedStyle
|
|
839
|
+
var div = document.createElement("div");
|
|
840
|
+
document.head.appendChild(div);
|
|
841
|
+
var bg = window.getComputedStyle(div).backgroundColor;
|
|
842
|
+
document.head.removeChild(div);
|
|
843
|
+
return bg;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
*
|
|
847
|
+
*/
|
|
848
|
+
_handleLoadComplete() {
|
|
849
|
+
// Stop and hide the spinner
|
|
850
|
+
this.hideSpinner();
|
|
851
|
+
this.stopSpinner();
|
|
852
|
+
/**
|
|
853
|
+
* Scene load has completed.
|
|
854
|
+
* @event avs-load-complete
|
|
855
|
+
*/
|
|
856
|
+
this.dispatchEvent(new CustomEvent('avs-load-complete'));
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
*
|
|
860
|
+
*/
|
|
861
|
+
_dispatchSceneData(data) {
|
|
862
|
+
/**
|
|
863
|
+
* Scene data from server.
|
|
864
|
+
* @event avs-scene-data
|
|
865
|
+
*/
|
|
866
|
+
this.dispatchEvent(new CustomEvent('avs-scene-data', { detail: data }));
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* @param e
|
|
870
|
+
*/
|
|
871
|
+
_handleTap(x, y, currentTarget) {
|
|
872
|
+
const adjustedCoords = this._getAdjustedCoords(x, y);
|
|
873
|
+
const pickProperties = {
|
|
874
|
+
type: "TAP",
|
|
875
|
+
x: adjustedCoords.x,
|
|
876
|
+
y: adjustedCoords.y,
|
|
877
|
+
level: this.tapLevel,
|
|
878
|
+
depth: this.tapDepth,
|
|
879
|
+
highlight: this.tapHighlightEnable,
|
|
880
|
+
highlightColor: this.tapHighlightColor,
|
|
881
|
+
highlightLayer: this.tapHighlightLayerEnable
|
|
882
|
+
};
|
|
883
|
+
this._processPick(pickProperties, this.tapProcessEventOnClient, currentTarget);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* @param e
|
|
887
|
+
*/
|
|
888
|
+
_handleTrack(state, x, y, dx, dy) {
|
|
889
|
+
var adjustedCoords = this._getAdjustedRectangleCoords(x, y, dx, dy);
|
|
890
|
+
switch (state) {
|
|
891
|
+
case 'start':
|
|
892
|
+
break;
|
|
893
|
+
case 'track':
|
|
894
|
+
this.rectCtx.clearRect(0, 0, this.width, this.height);
|
|
895
|
+
this._rectangleStyle();
|
|
896
|
+
this.rectCtx.strokeRect(adjustedCoords.left, adjustedCoords.top, adjustedCoords.right - adjustedCoords.left, adjustedCoords.bottom - adjustedCoords.top);
|
|
897
|
+
break;
|
|
898
|
+
case 'end':
|
|
899
|
+
this.rectCtx.clearRect(0, 0, this.width, this.height);
|
|
900
|
+
const pickProperties = {
|
|
901
|
+
type: "TRACK",
|
|
902
|
+
left: adjustedCoords.left,
|
|
903
|
+
right: adjustedCoords.right,
|
|
904
|
+
top: adjustedCoords.top,
|
|
905
|
+
bottom: adjustedCoords.bottom,
|
|
906
|
+
level: this.trackLevel,
|
|
907
|
+
depth: this.trackDepth,
|
|
908
|
+
highlight: this.trackHighlightEnable,
|
|
909
|
+
highlightColor: this.trackHighlightColor,
|
|
910
|
+
highlightLayer: this.trackHighlightLayerEnable
|
|
911
|
+
};
|
|
912
|
+
this._processPick(pickProperties, this.trackProcessEventOnClient);
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* @param e
|
|
918
|
+
*/
|
|
919
|
+
_handlePointerDown(e) {
|
|
920
|
+
this.pointerDownX = e.clientX;
|
|
921
|
+
this.pointerDownY = e.clientY;
|
|
922
|
+
this.pointerDown = true;
|
|
923
|
+
if (this.tapEnable && e.buttons & 1) {
|
|
924
|
+
this.tapping = true;
|
|
925
|
+
}
|
|
926
|
+
if (this.trackEnable && e.buttons & 2) {
|
|
927
|
+
this.tracking = 1;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* @param e
|
|
932
|
+
*/
|
|
933
|
+
_handlePointerMove(e) {
|
|
934
|
+
if (this.tracking >= 1) {
|
|
935
|
+
if (this.tracking === 1) {
|
|
936
|
+
var dx = Math.abs(e.clientX - this.pointerDownX);
|
|
937
|
+
var dy = Math.abs(e.clientY - this.pointerDownY);
|
|
938
|
+
if (dx * dx + dy * dy >= 5) {
|
|
939
|
+
this.tracking = 2;
|
|
940
|
+
this._handleTrack("start", e.clientX, e.clientY, e.clientX - this.pointerDownX, e.clientY - this.pointerDownY);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (this.tracking === 2) {
|
|
944
|
+
this._handleTrack("track", e.clientX, e.clientY, e.clientX - this.pointerDownX, e.clientY - this.pointerDownY);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
if (this.hoverEnable) {
|
|
948
|
+
var adjustedCoords = this._getAdjustedCoords(e.clientX, e.clientY);
|
|
949
|
+
const pickProperties = {
|
|
950
|
+
type: "HOVER",
|
|
951
|
+
x: adjustedCoords.x,
|
|
952
|
+
y: adjustedCoords.y
|
|
953
|
+
};
|
|
954
|
+
if (this.pointerDown) {
|
|
955
|
+
pickProperties.selected = [];
|
|
956
|
+
this._dispatchPickEvents(pickProperties);
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
if (this.hoverLevel !== undefined)
|
|
960
|
+
pickProperties.level = this.hoverLevel;
|
|
961
|
+
if (this.hoverDepth !== undefined)
|
|
962
|
+
pickProperties.depth = this.hoverDepth;
|
|
963
|
+
if (this.hoverHighlightEnable)
|
|
964
|
+
pickProperties.highlight = true;
|
|
965
|
+
if (this.hoverHighlightColor !== undefined)
|
|
966
|
+
pickProperties.highlightColor = this.hoverHighlightColor;
|
|
967
|
+
if (this.hoverHighlightLayerEnable)
|
|
968
|
+
pickProperties.highlightLayer = true;
|
|
969
|
+
this._processPick(pickProperties, true, e.target);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
this._resetTimer();
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* @param e
|
|
976
|
+
*/
|
|
977
|
+
_handlePointerUp(e) {
|
|
978
|
+
this.pointerDown = false;
|
|
979
|
+
if (this.tapping) {
|
|
980
|
+
this.tapping = false;
|
|
981
|
+
var dx = Math.abs(e.clientX - this.pointerDownX);
|
|
982
|
+
var dy = Math.abs(e.clientY - this.pointerDownY);
|
|
983
|
+
if (dx * dx + dy * dy < 25) {
|
|
984
|
+
this._handleTap(e.clientX, e.clientY, e.currentTarget);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (this.tracking > 1) {
|
|
988
|
+
this.tracking = 0;
|
|
989
|
+
this._handleTrack("end", e.clientX, e.clientY, e.clientX - this.pointerDownX, e.clientY - this.pointerDownY);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
_getAdjustedCoords(x, y) {
|
|
993
|
+
var rect = this.renderRoot.querySelector('#dataVizDiv').getBoundingClientRect();
|
|
994
|
+
var adjustedX = Math.round(x - rect.left);
|
|
995
|
+
var adjustedY = Math.round(y - rect.top);
|
|
996
|
+
var clampX = Math.max(0, Math.min(adjustedX, this.width));
|
|
997
|
+
var clampY = Math.max(0, Math.min(adjustedY, this.height));
|
|
998
|
+
return { x: clampX, y: clampY };
|
|
999
|
+
}
|
|
1000
|
+
_getAdjustedRectangleCoords(x, y, dx, dy) {
|
|
1001
|
+
var rect = this.renderRoot.querySelector('#dataVizDiv').getBoundingClientRect();
|
|
1002
|
+
var adjustedX = Math.round(x - rect.left);
|
|
1003
|
+
var adjustedY = Math.round(y - rect.top);
|
|
1004
|
+
var clampX = Math.max(0, Math.min(adjustedX, this.width));
|
|
1005
|
+
var clampY = Math.max(0, Math.min(adjustedY, this.height));
|
|
1006
|
+
var startX = Math.max(0, Math.min(adjustedX - dx, this.width));
|
|
1007
|
+
var startY = Math.max(0, Math.min(adjustedY - dy, this.height));
|
|
1008
|
+
var left = Math.min(startX, clampX);
|
|
1009
|
+
var right = Math.max(startX, clampX);
|
|
1010
|
+
var top = Math.min(startY, clampY);
|
|
1011
|
+
var bottom = Math.max(startY, clampY);
|
|
1012
|
+
return { left: left, right: right, top: top, bottom: bottom };
|
|
1013
|
+
}
|
|
1014
|
+
_processPick(pickProperties, processEventOnClient, originalTarget) {
|
|
1015
|
+
if (processEventOnClient) {
|
|
1016
|
+
if (this.threeViewer) {
|
|
1017
|
+
// ThreeJS client side pick processing
|
|
1018
|
+
this.threeViewer.setPickDepth(pickProperties.depth === "ALL" ? PickDepthEnum.All : PickDepthEnum.Closest);
|
|
1019
|
+
if (pickProperties.type === 'TRACK') {
|
|
1020
|
+
this.threeViewer.setPickRectangle(pickProperties.left, pickProperties.top, pickProperties.right, pickProperties.bottom);
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
this.threeViewer.setPickRay(pickProperties.x, pickProperties.y);
|
|
1024
|
+
}
|
|
1025
|
+
this.threeViewer.pick();
|
|
1026
|
+
var selectionList = {};
|
|
1027
|
+
if (pickProperties.level === "CELL") {
|
|
1028
|
+
selectionList = this.threeViewer.getPickedCells();
|
|
1029
|
+
}
|
|
1030
|
+
else if (pickProperties.level === "CELL_SET") {
|
|
1031
|
+
selectionList = this.threeViewer.getPickedCellSets();
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
selectionList = this.threeViewer.getPickedSceneNodes();
|
|
1035
|
+
}
|
|
1036
|
+
pickProperties.selected = this.threeViewer.getSelectionInfo(selectionList);
|
|
1037
|
+
this._dispatchPickEvents(pickProperties);
|
|
1038
|
+
if (pickProperties.highlight) {
|
|
1039
|
+
this.threeViewer.highlightColor.set(pickProperties.highlightColor);
|
|
1040
|
+
this.threeViewer.highlightObjects(selectionList, pickProperties.highlightLayer);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
else if (this.renderer === 'SVG') {
|
|
1044
|
+
// Client side SVG pick processing
|
|
1045
|
+
pickProperties.selected = [];
|
|
1046
|
+
if (pickProperties.type !== 'TRACK' && (originalTarget.nodeName === "polygon" || originalTarget.nodeName === "circle")) {
|
|
1047
|
+
const selectedInfo = {};
|
|
1048
|
+
var seriesIndex = null;
|
|
1049
|
+
var element = originalTarget.parentElement;
|
|
1050
|
+
while (element !== null && (seriesIndex = element.getAttribute("series-index")) === null) {
|
|
1051
|
+
element = element.parentElement;
|
|
1052
|
+
}
|
|
1053
|
+
if (seriesIndex !== null) {
|
|
1054
|
+
selectedInfo.seriesIndex = parseInt(seriesIndex);
|
|
1055
|
+
}
|
|
1056
|
+
var itemIndex = null;
|
|
1057
|
+
element = originalTarget.parentElement;
|
|
1058
|
+
while (element !== null && (itemIndex = element.getAttribute("item-index")) === null) {
|
|
1059
|
+
element = element.parentElement;
|
|
1060
|
+
}
|
|
1061
|
+
if (itemIndex !== null) {
|
|
1062
|
+
selectedInfo.itemIndex = parseInt(itemIndex);
|
|
1063
|
+
}
|
|
1064
|
+
var componentInfo = null;
|
|
1065
|
+
element = originalTarget.parentElement;
|
|
1066
|
+
while (element !== null && (componentInfo = element.getAttribute("component-info")) === null) {
|
|
1067
|
+
element = element.parentElement;
|
|
1068
|
+
}
|
|
1069
|
+
if (componentInfo !== null) {
|
|
1070
|
+
selectedInfo.componentInfo = decodeURIComponent(componentInfo);
|
|
1071
|
+
}
|
|
1072
|
+
pickProperties.selected.push(selectedInfo);
|
|
1073
|
+
}
|
|
1074
|
+
this._dispatchPickEvents(pickProperties);
|
|
1075
|
+
if (pickProperties.highlight) {
|
|
1076
|
+
if (this.highlightSvg === undefined) {
|
|
1077
|
+
this.highlightSvg = [];
|
|
1078
|
+
}
|
|
1079
|
+
for (var i = 0; i < this.highlightSvg.length; i++) {
|
|
1080
|
+
this.highlightSvg[i].setAttribute("fill", this.highlightSvg[i].getAttribute("saveFill"));
|
|
1081
|
+
}
|
|
1082
|
+
this.highlightSvg.length = 0;
|
|
1083
|
+
if (pickProperties.type !== 'TRACK' && (originalTarget.nodeName === "polygon" || originalTarget.nodeName === "circle")) {
|
|
1084
|
+
this.highlightSvg.push(originalTarget);
|
|
1085
|
+
originalTarget.setAttribute("saveFill", originalTarget.getAttribute("fill"));
|
|
1086
|
+
originalTarget.setAttribute("fill", pickProperties.highlightColor);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
else {
|
|
1091
|
+
// Client side imagemap pick processing
|
|
1092
|
+
pickProperties.selected = [];
|
|
1093
|
+
if (pickProperties.type !== 'TRACK' && this.imageMapData !== undefined) {
|
|
1094
|
+
for (var i = 0; i < this.imageMapData.length; i++) {
|
|
1095
|
+
var area = this.imageMapData[i];
|
|
1096
|
+
console.log(pickProperties.x + " " + pickProperties.y);
|
|
1097
|
+
if (area.shape === "poly" && this._pointInPoly(pickProperties.x, pickProperties.y, area.coords)) {
|
|
1098
|
+
const selectedInfo = {};
|
|
1099
|
+
if (area.seriesIndex !== null) {
|
|
1100
|
+
selectedInfo.seriesIndex = parseInt(area.seriesIndex);
|
|
1101
|
+
}
|
|
1102
|
+
if (area.itemIndex !== null) {
|
|
1103
|
+
selectedInfo.itemIndex = parseInt(area.itemIndex);
|
|
1104
|
+
}
|
|
1105
|
+
if (area.componentInfo !== null) {
|
|
1106
|
+
selectedInfo.componentInfo = decodeURIComponent(area.componentInfo);
|
|
1107
|
+
}
|
|
1108
|
+
pickProperties.selected.push(selectedInfo);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
this._dispatchPickEvents(pickProperties);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
else if (!this.urlLoadJsonFile) {
|
|
1116
|
+
// Server side pick processing
|
|
1117
|
+
this.showSpinner();
|
|
1118
|
+
if (this.url) {
|
|
1119
|
+
this.startSpinner();
|
|
1120
|
+
// Send the model to the server
|
|
1121
|
+
this.model = this._assembleModel();
|
|
1122
|
+
if (this.model) {
|
|
1123
|
+
this.model.rendererProperties.pickProperties = pickProperties;
|
|
1124
|
+
this._httpRequest(this.url, this._handleHttpResponse.bind(this), this._handleHttpError.bind(this), this.model);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
_pointInPoly(x, y, coords) {
|
|
1130
|
+
var dx1 = coords[0] - x;
|
|
1131
|
+
var dy1 = coords[1] - y;
|
|
1132
|
+
var dx2, dy2, f;
|
|
1133
|
+
var k = 0;
|
|
1134
|
+
for (var i = 2; i < coords.length; i += 2) {
|
|
1135
|
+
dy2 = coords[i + 1] - y;
|
|
1136
|
+
if ((dy1 < 0 && dy2 < 0) || (dy1 > 0 && dy2 > 0)) {
|
|
1137
|
+
dy1 = dy2;
|
|
1138
|
+
dx1 = coords[i] - x;
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
dx2 = coords[i] - x;
|
|
1142
|
+
if (dy2 > 0 && dy1 <= 0) {
|
|
1143
|
+
f = (dx1 * dy2) - (dx2 * dy1);
|
|
1144
|
+
if (f > 0)
|
|
1145
|
+
k++;
|
|
1146
|
+
else if (f === 0)
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
else if (dy1 > 0 && dy2 <= 0) {
|
|
1150
|
+
f = (dx1 * dy2) - (dx2 * dy1);
|
|
1151
|
+
if (f < 0)
|
|
1152
|
+
k++;
|
|
1153
|
+
else if (f === 0)
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
else if (dy2 === 0 && dy1 < 0) {
|
|
1157
|
+
f = (dx1 * dy2) - (dx2 * dy1);
|
|
1158
|
+
if (f === 0)
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
else if (dy1 === 0 && dy2 < 0) {
|
|
1162
|
+
f = dx1 * dy2 - dx2 * dy1;
|
|
1163
|
+
if (f === 0)
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
else if (dy1 === 0 && dy2 === 0) {
|
|
1167
|
+
if (dx2 <= 0 && dx1 >= 0) {
|
|
1168
|
+
return false;
|
|
1169
|
+
}
|
|
1170
|
+
else if (dx1 <= 0 && dx2 >= 0) {
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
dy1 = dy2;
|
|
1175
|
+
dx1 = dx2;
|
|
1176
|
+
}
|
|
1177
|
+
if (k % 2 === 0)
|
|
1178
|
+
return false;
|
|
1179
|
+
return true;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Dispatch the appropriate tap, track or hover event.
|
|
1183
|
+
*/
|
|
1184
|
+
_dispatchPickEvents(pickProperties) {
|
|
1185
|
+
const pickDetail = {
|
|
1186
|
+
selected: pickProperties.selected
|
|
1187
|
+
};
|
|
1188
|
+
if (pickProperties.type === 'TRACK') {
|
|
1189
|
+
pickDetail.left = pickProperties.left;
|
|
1190
|
+
pickDetail.top = pickProperties.top;
|
|
1191
|
+
pickDetail.right = pickProperties.right;
|
|
1192
|
+
pickDetail.bottom = pickProperties.bottom;
|
|
1193
|
+
/**
|
|
1194
|
+
* A track event occurred.
|
|
1195
|
+
* @event avs-track
|
|
1196
|
+
*/
|
|
1197
|
+
this.dispatchEvent(new CustomEvent('avs-track', { detail: pickDetail }));
|
|
1198
|
+
}
|
|
1199
|
+
else {
|
|
1200
|
+
pickDetail.x = pickProperties.x;
|
|
1201
|
+
pickDetail.y = pickProperties.y;
|
|
1202
|
+
if (pickProperties.type === 'HOVER') {
|
|
1203
|
+
/**
|
|
1204
|
+
* A hover event occurred.
|
|
1205
|
+
* @event avs-hover
|
|
1206
|
+
*/
|
|
1207
|
+
this.dispatchEvent(new CustomEvent('avs-hover', { detail: pickDetail }));
|
|
1208
|
+
}
|
|
1209
|
+
else {
|
|
1210
|
+
/**
|
|
1211
|
+
* A tap event occurred.
|
|
1212
|
+
* @event avs-tap
|
|
1213
|
+
*/
|
|
1214
|
+
this.dispatchEvent(new CustomEvent('avs-tap', { detail: pickDetail }));
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
_resetTimer() {
|
|
1219
|
+
window.clearTimeout(this.timer);
|
|
1220
|
+
this.timer = window.setTimeout(() => {
|
|
1221
|
+
/**
|
|
1222
|
+
* A pointer timeout event occurred.
|
|
1223
|
+
* @event avs-pointer-timeout
|
|
1224
|
+
*/
|
|
1225
|
+
this.dispatchEvent(new Event('avs-pointer-timeout'));
|
|
1226
|
+
}, this.pointerTimeout * 1000);
|
|
1227
|
+
}
|
|
1228
|
+
constructor() {
|
|
1229
|
+
super();
|
|
1230
|
+
// Set default property values
|
|
1231
|
+
this.renderer = Renderer.THREEJS;
|
|
1232
|
+
this.resizeThreshold = 10;
|
|
1233
|
+
this.pointerTimeout = 600;
|
|
1234
|
+
this.panWidthZoomLevel = 100;
|
|
1235
|
+
this.panHeightZoomLevel = 100;
|
|
1236
|
+
this.panMaximumZoomLevel = 1000;
|
|
1237
|
+
this.lowResizeWidth = this.highResizeWidth = 0;
|
|
1238
|
+
this.highResizeWidth = this.highResizeHeight = 0;
|
|
1239
|
+
this.motionCaptureTime = 0;
|
|
1240
|
+
this.motionCaptureFrames ??= [];
|
|
1241
|
+
this._resetTimer();
|
|
1242
|
+
this._updatePixelRatio();
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Element connected to the DOM
|
|
1246
|
+
*/
|
|
1247
|
+
connectedCallback() {
|
|
1248
|
+
super.connectedCallback();
|
|
1249
|
+
ro.observe(this);
|
|
1250
|
+
this.addEventListener('pointerdown', this._handlePointerDown);
|
|
1251
|
+
this.addEventListener('pointerup', this._handlePointerUp);
|
|
1252
|
+
this.addEventListener('pointermove', this._handlePointerMove);
|
|
1253
|
+
this.addEventListener('pointerout', this._handlePointerMove);
|
|
1254
|
+
var scope = this;
|
|
1255
|
+
this.addEventListener('contextmenu', function (e) {
|
|
1256
|
+
if (scope.trackEnable) {
|
|
1257
|
+
e.preventDefault();
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Element disconnected from the DOM
|
|
1263
|
+
*/
|
|
1264
|
+
disconnectedCallback() {
|
|
1265
|
+
super.disconnectedCallback();
|
|
1266
|
+
ro.unobserve(this);
|
|
1267
|
+
}
|
|
1268
|
+
_handlePointerEnterMotionCaptureControl(e) {
|
|
1269
|
+
if (!this.showMotionCaptureTooltip) {
|
|
1270
|
+
var adjustedCoords = this._getAdjustedCoords(e.clientX, e.clientY);
|
|
1271
|
+
var motionCaptureTooltip = this.renderRoot.querySelector('#motionCaptureTooltip');
|
|
1272
|
+
var pos = this._calcTooltipPosition(motionCaptureTooltip, adjustedCoords.x, adjustedCoords.y);
|
|
1273
|
+
motionCaptureTooltip.style.left = pos.x + "px";
|
|
1274
|
+
motionCaptureTooltip.style.top = pos.y + "px";
|
|
1275
|
+
motionCaptureTooltip.style.opacity = "1";
|
|
1276
|
+
const target = e.currentTarget;
|
|
1277
|
+
motionCaptureTooltip.innerHTML = target.dataset.tooltip ?? target.id;
|
|
1278
|
+
this.showMotionCaptureTooltip = true;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
_handlePointerLeaveMotionCaptureControl() {
|
|
1282
|
+
var motionCaptureTooltip = this.renderRoot.querySelector('#motionCaptureTooltip');
|
|
1283
|
+
motionCaptureTooltip.style.opacity = "0";
|
|
1284
|
+
this.showMotionCaptureTooltip = false;
|
|
1285
|
+
}
|
|
1286
|
+
_round2dp(n) {
|
|
1287
|
+
return Math.round((n + Number.EPSILON) * 100) / 100;
|
|
1288
|
+
}
|
|
1289
|
+
_handleMotionCaptureSnapshot() {
|
|
1290
|
+
const transform = this._getTransformComponents();
|
|
1291
|
+
if (this.motionCaptureFrames.length > 0) {
|
|
1292
|
+
this.motionCaptureTime += this.motionCaptureDelay;
|
|
1293
|
+
}
|
|
1294
|
+
const frame = {
|
|
1295
|
+
time: this.motionCaptureTime * 1000,
|
|
1296
|
+
scale: this._round2dp(transform.scale),
|
|
1297
|
+
position: [this._round2dp(transform.position[0]),
|
|
1298
|
+
this._round2dp(transform.position[1]),
|
|
1299
|
+
this._round2dp(transform.position[2])],
|
|
1300
|
+
rotation: [this._round2dp(transform.rotation[0]),
|
|
1301
|
+
this._round2dp(transform.rotation[1]),
|
|
1302
|
+
this._round2dp(transform.rotation[2]),
|
|
1303
|
+
transform.rotation[3]]
|
|
1304
|
+
};
|
|
1305
|
+
this.motionCaptureFrames.push(frame);
|
|
1306
|
+
if (this.motionCaptureFrames.length == 1) {
|
|
1307
|
+
this.renderRoot.querySelector('#motionCapturePlay').classList.remove("disabled");
|
|
1308
|
+
this.renderRoot.querySelector('#motionCaptureDelay').classList.remove("disabled");
|
|
1309
|
+
this.renderRoot.querySelector('#motionCaptureDelayLabel').innerHTML = "2";
|
|
1310
|
+
this.renderRoot.querySelector('#motionCaptureClear').classList.remove("disabled");
|
|
1311
|
+
this.renderRoot.querySelector('#motionCaptureCopyData').classList.remove("disabled");
|
|
1312
|
+
this.renderRoot.querySelector('#motionCaptureCopyUrl').classList.remove("disabled");
|
|
1313
|
+
this.motionCaptureDelay = 2;
|
|
1314
|
+
}
|
|
1315
|
+
this.renderRoot.querySelector('#motionCaptureSnapshotLabel').innerHTML = String(this.motionCaptureFrames.length);
|
|
1316
|
+
}
|
|
1317
|
+
_handleMotionCaptureDelayIncrease() {
|
|
1318
|
+
this.motionCaptureDelay++;
|
|
1319
|
+
if (this.motionCaptureDelay > 9) {
|
|
1320
|
+
this.motionCaptureDelay = 9;
|
|
1321
|
+
}
|
|
1322
|
+
this.renderRoot.querySelector('#motionCaptureDelayLabel').innerHTML = String(this.motionCaptureDelay);
|
|
1323
|
+
}
|
|
1324
|
+
_handleMotionCaptureDelayDecrease() {
|
|
1325
|
+
this.motionCaptureDelay--;
|
|
1326
|
+
if (this.motionCaptureDelay < 1) {
|
|
1327
|
+
this.motionCaptureDelay = 1;
|
|
1328
|
+
}
|
|
1329
|
+
this.renderRoot.querySelector('#motionCaptureDelayLabel').innerHTML = String(this.motionCaptureDelay);
|
|
1330
|
+
}
|
|
1331
|
+
_handleMotionCaptureCopyData() {
|
|
1332
|
+
// Convert to JSON and copy to clipboard
|
|
1333
|
+
const data = JSON.stringify(this.motionCaptureFrames);
|
|
1334
|
+
navigator.clipboard.writeText(data);
|
|
1335
|
+
// Show alert
|
|
1336
|
+
const motionCaptureAlert = this.renderRoot.querySelector('#motionCaptureAlert');
|
|
1337
|
+
motionCaptureAlert.innerHTML = "Motion capture URL copied to clipboard";
|
|
1338
|
+
motionCaptureAlert.style.opacity = "1";
|
|
1339
|
+
setTimeout(() => {
|
|
1340
|
+
motionCaptureAlert.style.opacity = "0";
|
|
1341
|
+
}, 2000);
|
|
1342
|
+
}
|
|
1343
|
+
async _handleMotionCaptureCopyUrl() {
|
|
1344
|
+
// Convert to JSON, compress and base64url encode
|
|
1345
|
+
const json = JSON.stringify(this.motionCaptureFrames);
|
|
1346
|
+
const compressed = await this._compress(json);
|
|
1347
|
+
const encoded = btoa(String.fromCharCode(...new Uint8Array(compressed))).replaceAll('/', '_').replaceAll('+', '-');
|
|
1348
|
+
// Create URL and copy to clipboard
|
|
1349
|
+
const url = window.location.origin + window.location.pathname + "?motionCapture=" + encoded;
|
|
1350
|
+
navigator.clipboard.writeText(url);
|
|
1351
|
+
// Show alert
|
|
1352
|
+
const motionCaptureAlert = this.renderRoot.querySelector('#motionCaptureAlert');
|
|
1353
|
+
motionCaptureAlert.innerHTML = "Motion capture URL copied to clipboard";
|
|
1354
|
+
motionCaptureAlert.style.opacity = "1";
|
|
1355
|
+
setTimeout(() => {
|
|
1356
|
+
motionCaptureAlert.style.opacity = "0";
|
|
1357
|
+
}, 2000);
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Convert a string to its UTF-8 bytes and compress it.
|
|
1361
|
+
*
|
|
1362
|
+
* @param {string} str
|
|
1363
|
+
* @returns {Promise<Uint8Array>}
|
|
1364
|
+
*/
|
|
1365
|
+
async _compress(str) {
|
|
1366
|
+
// Convert the string to a byte stream.
|
|
1367
|
+
const stream = new Blob([str]).stream();
|
|
1368
|
+
// Create a compressed stream.
|
|
1369
|
+
const compressedStream = stream.pipeThrough(new CompressionStream("gzip"));
|
|
1370
|
+
// Read all the bytes from this stream.
|
|
1371
|
+
const chunks = [];
|
|
1372
|
+
for await (const chunk of compressedStream) {
|
|
1373
|
+
chunks.push(chunk);
|
|
1374
|
+
}
|
|
1375
|
+
return this._concatUint8Arrays(chunks);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Decompress bytes into a UTF-8 string.
|
|
1379
|
+
*
|
|
1380
|
+
* @param {Uint8Array} compressedBytes
|
|
1381
|
+
* @returns {Promise<string>}
|
|
1382
|
+
*/
|
|
1383
|
+
async _decompress(compressedBytes) {
|
|
1384
|
+
// Convert the bytes to a stream.
|
|
1385
|
+
const stream = new Blob([compressedBytes]).stream();
|
|
1386
|
+
// Create a decompressed stream.
|
|
1387
|
+
const decompressedStream = stream.pipeThrough(new DecompressionStream("gzip"));
|
|
1388
|
+
// Read all the bytes from this stream.
|
|
1389
|
+
const chunks = [];
|
|
1390
|
+
for await (const chunk of decompressedStream) {
|
|
1391
|
+
chunks.push(chunk);
|
|
1392
|
+
}
|
|
1393
|
+
const stringBytes = await this._concatUint8Arrays(chunks);
|
|
1394
|
+
// Convert the bytes to a string.
|
|
1395
|
+
return new TextDecoder().decode(stringBytes);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Combine multiple Uint8Arrays into one.
|
|
1399
|
+
*
|
|
1400
|
+
* @param {ReadonlyArray<Uint8Array>} uint8arrays
|
|
1401
|
+
* @returns {Promise<Uint8Array>}
|
|
1402
|
+
*/
|
|
1403
|
+
async _concatUint8Arrays(uint8arrays) {
|
|
1404
|
+
const blob = new Blob(uint8arrays);
|
|
1405
|
+
const buffer = await blob.arrayBuffer();
|
|
1406
|
+
return new Uint8Array(buffer);
|
|
1407
|
+
}
|
|
1408
|
+
_handleMotionCaptureClear() {
|
|
1409
|
+
this.motionCaptureFrames.length = 0;
|
|
1410
|
+
this.renderRoot.querySelector('#motionCapturePlay').classList.add("disabled");
|
|
1411
|
+
this.renderRoot.querySelector('#motionCaptureSnapshotLabel').innerHTML = "0";
|
|
1412
|
+
this.renderRoot.querySelector('#motionCaptureDelay').classList.add("disabled");
|
|
1413
|
+
this.renderRoot.querySelector('#motionCaptureDelayLabel').innerHTML = "0";
|
|
1414
|
+
this.renderRoot.querySelector('#motionCaptureClear').classList.add("disabled");
|
|
1415
|
+
this.renderRoot.querySelector('#motionCaptureCopyData').classList.add("disabled");
|
|
1416
|
+
this.renderRoot.querySelector('#motionCaptureCopyUrl').classList.add("disabled");
|
|
1417
|
+
this.motionCaptureDelay = 0;
|
|
1418
|
+
this.motionCaptureTime = 0;
|
|
1419
|
+
}
|
|
1420
|
+
_updatePixelRatio(change) {
|
|
1421
|
+
const pr = window.devicePixelRatio;
|
|
1422
|
+
matchMedia(`(resolution: ${pr}dppx)`).addEventListener('change', this._updatePixelRatio.bind(this, true), { once: true });
|
|
1423
|
+
if (change) {
|
|
1424
|
+
this.updateViewer();
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Change in 'motion-capture-controls-enable' property.
|
|
1429
|
+
*/
|
|
1430
|
+
_motionCaptureControlsEnableChanged(newValue, oldValue) {
|
|
1431
|
+
const el = this.renderRoot.querySelector('#motionCapture');
|
|
1432
|
+
el.style.display = newValue ? "block" : "none";
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Change in 'transform-enable' property.
|
|
1436
|
+
*/
|
|
1437
|
+
_transformEnableChanged(newValue, oldValue) {
|
|
1438
|
+
if (this.threeViewer) {
|
|
1439
|
+
if (newValue) {
|
|
1440
|
+
if (this.transformInteractor === undefined) {
|
|
1441
|
+
this.transformInteractor = new TransformInteractor(this.renderRoot.querySelector('#dataVizDiv'));
|
|
1442
|
+
}
|
|
1443
|
+
this.threeViewer.addInteractor(this.transformInteractor);
|
|
1444
|
+
if (this.transformRotateDisable) {
|
|
1445
|
+
this.transformInteractor.enableRotate = false;
|
|
1446
|
+
}
|
|
1447
|
+
if (this.transformZoomDisable) {
|
|
1448
|
+
this.transformInteractor.enableZoom = false;
|
|
1449
|
+
}
|
|
1450
|
+
if (this.transformPanDisable) {
|
|
1451
|
+
this.transformInteractor.enablePan = false;
|
|
1452
|
+
}
|
|
1453
|
+
if (this.transformClientOnly) {
|
|
1454
|
+
this.transformInteractor.clientOnly = true;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
this.threeViewer.removeInteractor(this.transformInteractor);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Change in the 'transform-client-only' property.
|
|
1464
|
+
*/
|
|
1465
|
+
_transformClientOnlyChanged(newValue, oldValue) {
|
|
1466
|
+
if (this.transformInteractor) {
|
|
1467
|
+
this.transformInteractor.clientOnly = newValue;
|
|
1468
|
+
}
|
|
1469
|
+
if (this.zoomRectangleInteractor) {
|
|
1470
|
+
this.zoomRectangleInteractor.clientOnly = newValue;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Change in 'transform-rotate-disable' property.
|
|
1475
|
+
*/
|
|
1476
|
+
_transformRotateDisableChanged(newValue, oldValue) {
|
|
1477
|
+
if (this.transformInteractor) {
|
|
1478
|
+
this.transformInteractor.enableRotate = !newValue;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Change in 'transform-zoom-disable' property.
|
|
1483
|
+
*/
|
|
1484
|
+
_transformZoomDisableChanged(newValue, oldValue) {
|
|
1485
|
+
if (this.transformInteractor) {
|
|
1486
|
+
this.transformInteractor.enableZoom = !newValue;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Change in 'transform-pan-disable' property.
|
|
1491
|
+
*/
|
|
1492
|
+
_transformPanDisableChanged(newValue, oldValue) {
|
|
1493
|
+
if (this.transformInteractor) {
|
|
1494
|
+
this.transformInteractor.enablePan = !newValue;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Reset the transform interactor.
|
|
1499
|
+
*/
|
|
1500
|
+
resetTransform() {
|
|
1501
|
+
if (this.transformInteractor) {
|
|
1502
|
+
this.transformInteractor.reset();
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Perform a zoom in using the transform interactor.
|
|
1507
|
+
*/
|
|
1508
|
+
zoomIn() {
|
|
1509
|
+
if (this.transformInteractor) {
|
|
1510
|
+
this.transformInteractor.zoomIn();
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Perform a zoom out using the transform interactor.
|
|
1515
|
+
*/
|
|
1516
|
+
zoomOut() {
|
|
1517
|
+
if (this.transformInteractor) {
|
|
1518
|
+
this.transformInteractor.zoomOut();
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Perform a pan to center the specified coordinate of the transformed object in the center of the scene.
|
|
1523
|
+
*/
|
|
1524
|
+
panTo(x, y, z) {
|
|
1525
|
+
if (this.transformInteractor) {
|
|
1526
|
+
this.transformInteractor.panTo(x, y, z);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
_getTransformComponents() {
|
|
1530
|
+
var pos = new Vector3();
|
|
1531
|
+
var quat = new Quaternion();
|
|
1532
|
+
var scale = new Vector3();
|
|
1533
|
+
var euler = new Euler();
|
|
1534
|
+
var mat;
|
|
1535
|
+
if (this.transformInteractor) {
|
|
1536
|
+
mat = this.transformInteractor.object.matrix;
|
|
1537
|
+
}
|
|
1538
|
+
mat.decompose(pos, quat, scale);
|
|
1539
|
+
euler.setFromQuaternion(quat);
|
|
1540
|
+
return {
|
|
1541
|
+
position: pos.toArray(),
|
|
1542
|
+
rotation: [euler.x * 180 / Math.PI, euler.y * 180 / Math.PI, euler.z * 180 / Math.PI],
|
|
1543
|
+
rotationOrder: euler.order,
|
|
1544
|
+
scale: 100 * scale.x
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
getTransformMatrix() {
|
|
1548
|
+
if (this.transformInteractor) {
|
|
1549
|
+
return this.transformInteractor.object.matrix.elements.slice();
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
runAnimation() {
|
|
1553
|
+
if (this.threeViewer) {
|
|
1554
|
+
var style = window.getComputedStyle(this, null);
|
|
1555
|
+
var styleMap = {
|
|
1556
|
+
transform: this.motionCaptureFrames.length > 0 ? JSON.stringify(this.motionCaptureFrames) : null
|
|
1557
|
+
};
|
|
1558
|
+
this._applyCustomCssProperties(styleMap, style, {
|
|
1559
|
+
"scene": "--avs-scene-animations",
|
|
1560
|
+
"sceneTitle": "--avs-scene-title-animations",
|
|
1561
|
+
"chart": "--avs-chart-animations",
|
|
1562
|
+
"chartTitle": "--avs-chart-title-animations",
|
|
1563
|
+
"axis": "--avs-axis-animations",
|
|
1564
|
+
"legend": "--avs-legend-animations",
|
|
1565
|
+
"legendTitle": "--avs-legend-title-animations",
|
|
1566
|
+
"glyph": "--avs-glyph-animations"
|
|
1567
|
+
});
|
|
1568
|
+
this.animator.setStyleMap(styleMap);
|
|
1569
|
+
this.threeViewer.runAnimation();
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Change in 'animated-glyphs-visible' property.
|
|
1574
|
+
*/
|
|
1575
|
+
_animatedGlyphsVisibleChanged(newValue, oldValue) {
|
|
1576
|
+
if (this.threeViewer) {
|
|
1577
|
+
this.threeViewer.setVisibleAnimatedGlyphs(newValue);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Change in 'animated-glyphs-enable' property.
|
|
1582
|
+
*/
|
|
1583
|
+
_animatedGlyphsEnableChanged(newValue, oldValue) {
|
|
1584
|
+
if (this.threeViewer) {
|
|
1585
|
+
this.threeViewer.setEnableAnimatedGlyphs(newValue);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Change in 'transform-twist-angle', 'transform-tilt-angle' or 'transform-scale' properties.
|
|
1590
|
+
*/
|
|
1591
|
+
_transformValueChanged() {
|
|
1592
|
+
var twist = this.transformTwistAngle !== undefined ? this.transformTwistAngle * Math.PI / 180 : 0;
|
|
1593
|
+
var tilt = this.transformTiltAngle !== undefined ? this.transformTiltAngle * Math.PI / 180 : 0;
|
|
1594
|
+
var scale = this.transformScale !== undefined ? this.transformScale / 100.0 : 1.0;
|
|
1595
|
+
var sinTW = Math.sin(twist);
|
|
1596
|
+
var cosTW = Math.cos(twist);
|
|
1597
|
+
var sinTI = Math.sin(tilt);
|
|
1598
|
+
var cosTI = Math.cos(tilt);
|
|
1599
|
+
var matrix = [cosTW * scale, 0, cosTI * sinTW * scale, 0,
|
|
1600
|
+
0, cosTI * scale, -sinTI * scale, 0,
|
|
1601
|
+
-sinTW * scale, cosTW * sinTI * scale, cosTW * cosTI * scale, 0,
|
|
1602
|
+
0, 0, 0, 1];
|
|
1603
|
+
this.transformMatrix = matrix;
|
|
1604
|
+
if (this.transformInteractor) {
|
|
1605
|
+
this.transformInteractor.object.matrix.fromArray(matrix);
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* Change in 'motion-capture' property.
|
|
1610
|
+
*/
|
|
1611
|
+
async _motionCaptureValueChanged(newValue, oldValue) {
|
|
1612
|
+
if (newValue) {
|
|
1613
|
+
// Try parsing JSON first
|
|
1614
|
+
try {
|
|
1615
|
+
this.motionCaptureFrames = JSON.parse(newValue);
|
|
1616
|
+
}
|
|
1617
|
+
catch {
|
|
1618
|
+
// Decode from base64url, decompress and parse JSON
|
|
1619
|
+
const decoded = atob(newValue).replaceAll('_', '/').replaceAll('-', '+');
|
|
1620
|
+
const decompressed = await this._decompress(decoded);
|
|
1621
|
+
this.motionCaptureFrames = JSON.parse(decompressed);
|
|
1622
|
+
}
|
|
1623
|
+
if (!this.motionCaptureFrames) {
|
|
1624
|
+
this.motionCaptureFrames = [];
|
|
1625
|
+
}
|
|
1626
|
+
if (this.motionCaptureFrames.length > 0) {
|
|
1627
|
+
this.renderRoot.querySelector('#motionCapturePlay').classList.remove("disabled");
|
|
1628
|
+
this.renderRoot.querySelector('#motionCaptureSnapshotLabel').innerHTML = String(this.motionCaptureFrames.length);
|
|
1629
|
+
this.renderRoot.querySelector('#motionCaptureDelay').classList.remove("disabled");
|
|
1630
|
+
this.renderRoot.querySelector('#motionCaptureDelayLabel').innerHTML = "2";
|
|
1631
|
+
this.renderRoot.querySelector('#motionCaptureClear').classList.remove("disabled");
|
|
1632
|
+
this.renderRoot.querySelector('#motionCaptureCopyData').classList.remove("disabled");
|
|
1633
|
+
this.renderRoot.querySelector('#motionCaptureCopyUrl').classList.remove("disabled");
|
|
1634
|
+
this.motionCaptureDelay = 2;
|
|
1635
|
+
this.motionCaptureTime = this.motionCaptureFrames[this.motionCaptureFrames.length - 1].time / 1000;
|
|
1636
|
+
}
|
|
1637
|
+
else {
|
|
1638
|
+
this.renderRoot.querySelector('#motionCapturePlay').classList.add("disabled");
|
|
1639
|
+
this.renderRoot.querySelector('#motionCaptureSnapshotLabel').innerHTML = "0";
|
|
1640
|
+
this.renderRoot.querySelector('#motionCaptureDelay').classList.add("disabled");
|
|
1641
|
+
this.renderRoot.querySelector('#motionCaptureDelayLabel').innerHTML = "0";
|
|
1642
|
+
this.renderRoot.querySelector('#motionCaptureClear').classList.add("disabled");
|
|
1643
|
+
this.renderRoot.querySelector('#motionCaptureCopyData').classList.add("disabled");
|
|
1644
|
+
this.renderRoot.querySelector('#motionCaptureCopyUrl').classList.add("disabled");
|
|
1645
|
+
this.motionCaptureDelay = 0;
|
|
1646
|
+
this.motionCaptureTime = 0;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Change in 'zoom-rectangle-enable' property.
|
|
1652
|
+
*/
|
|
1653
|
+
_zoomRectangleEnableChanged(newValue, oldValue) {
|
|
1654
|
+
if (this.threeViewer) {
|
|
1655
|
+
if (newValue) {
|
|
1656
|
+
if (this.zoomRectangleInteractor === undefined) {
|
|
1657
|
+
this.zoomRectangleInteractor = new ZoomRectangleInteractor(this);
|
|
1658
|
+
}
|
|
1659
|
+
this.threeViewer.addInteractor(this.zoomRectangleInteractor);
|
|
1660
|
+
if (this.transformClientOnly) {
|
|
1661
|
+
this.zoomRectangleInteractor.clientOnly = true;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
else {
|
|
1665
|
+
this.threeViewer.removeInteractor(this.zoomRectangleInteractor);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Change in 'pan-enable' property.
|
|
1671
|
+
*/
|
|
1672
|
+
_panEnableChanged(newValue, oldValue) {
|
|
1673
|
+
if (this.threeViewer) {
|
|
1674
|
+
if (newValue) {
|
|
1675
|
+
if (this.panInteractor === undefined) {
|
|
1676
|
+
this.panInteractor = new PanInteractor(this);
|
|
1677
|
+
}
|
|
1678
|
+
this.threeViewer.addInteractor(this.panInteractor);
|
|
1679
|
+
if (this.panZoomEnable) {
|
|
1680
|
+
this.panInteractor.addEventListener('change', this._handlePanChanged.bind(this));
|
|
1681
|
+
this.panInteractor.addEventListener('zoom', this._handlePanZoom.bind(this));
|
|
1682
|
+
this.panInteractor.addEventListener('zoomEnd', this._handlePanZoomEnd.bind(this));
|
|
1683
|
+
}
|
|
1684
|
+
this.panInteractor.setWidthZoomLevel(this.panWidthZoomLevel);
|
|
1685
|
+
this.panInteractor.setHeightZoomLevel(this.panHeightZoomLevel);
|
|
1686
|
+
this.panInteractor.setMaximumZoomLevel(this.panMaximumZoomLevel);
|
|
1687
|
+
this.panInteractor.saveState();
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
this.threeViewer.removeInteractor(this.panInteractor);
|
|
1691
|
+
if (this.panZoomEnable) {
|
|
1692
|
+
this.panInteractor.removeEventListener('change', this._handlePanChanged.bind(this));
|
|
1693
|
+
this.panInteractor.removeEventListener('zoom', this._handlePanZoom.bind(this));
|
|
1694
|
+
this.panInteractor.removeEventListener('zoomEnd', this._handlePanZoomEnd.bind(this));
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Change in 'pan-zoom-enable' property.
|
|
1701
|
+
*/
|
|
1702
|
+
_panZoomEnableChanged(newValue, oldValue) {
|
|
1703
|
+
if (this.threeViewer && this.panInteractor) {
|
|
1704
|
+
if (newValue) {
|
|
1705
|
+
this.panInteractor.addEventListener('change', this._handlePanChanged.bind(this));
|
|
1706
|
+
this.panInteractor.addEventListener('zoom', this._handlePanZoom.bind(this));
|
|
1707
|
+
this.panInteractor.addEventListener('zoomEnd', this._handlePanZoomEnd.bind(this));
|
|
1708
|
+
}
|
|
1709
|
+
else {
|
|
1710
|
+
this.panInteractor.removeEventListener('change', this._handlePanChanged.bind(this));
|
|
1711
|
+
this.panInteractor.removeEventListener('zoom', this._handlePanZoom.bind(this));
|
|
1712
|
+
this.panInteractor.removeEventListener('zoomEnd', this._handlePanZoomEnd.bind(this));
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
_handlePanChanged(e) {
|
|
1717
|
+
/**
|
|
1718
|
+
* A pan info event occurred.
|
|
1719
|
+
* @event avs-pan-info
|
|
1720
|
+
*/
|
|
1721
|
+
this.dispatchEvent(new CustomEvent('avs-pan-info', e));
|
|
1722
|
+
}
|
|
1723
|
+
_handlePanZoom(e) {
|
|
1724
|
+
window.clearTimeout(this.zoomOverlayTimeoutId);
|
|
1725
|
+
var width = Math.round(e.detail.widthZoomLevel);
|
|
1726
|
+
var height = Math.round(e.detail.heightZoomLevel);
|
|
1727
|
+
if (width === height) {
|
|
1728
|
+
this.renderRoot.querySelector('#zoomOverlay').innerHTML = width + "%";
|
|
1729
|
+
}
|
|
1730
|
+
else {
|
|
1731
|
+
this.renderRoot.querySelector('#zoomOverlay').innerHTML = width + "%," + height + "%";
|
|
1732
|
+
}
|
|
1733
|
+
var coords = this._getAdjustedCoords(e.detail.clientX, e.detail.clientY);
|
|
1734
|
+
const zoomOverlay = this.renderRoot.querySelector('#zoomOverlay');
|
|
1735
|
+
zoomOverlay.style.left = coords.x + "px";
|
|
1736
|
+
zoomOverlay.style.top = coords.y + "px";
|
|
1737
|
+
zoomOverlay.style.opacity = "1";
|
|
1738
|
+
this.pointerDown = true;
|
|
1739
|
+
this._dispatchPickEvents({ type: "HOVER", x: 0, y: 0, selected: [] });
|
|
1740
|
+
this.zoomOverlayTimeoutId = window.setTimeout(() => {
|
|
1741
|
+
const el = this.renderRoot.querySelector('#zoomOverlay');
|
|
1742
|
+
el.style.opacity = "0";
|
|
1743
|
+
this.pointerDown = false;
|
|
1744
|
+
}, 1000);
|
|
1745
|
+
}
|
|
1746
|
+
_handlePanZoomEnd(e) {
|
|
1747
|
+
this.panWidthZoomLevel = e.detail.widthZoomLevel;
|
|
1748
|
+
this.panHeightZoomLevel = e.detail.heightZoomLevel;
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Change in 'pan-width-zoom-level' property.
|
|
1752
|
+
*/
|
|
1753
|
+
_panWidthZoomLevelChanged(newValue, oldValue) {
|
|
1754
|
+
if (this.panInteractor) {
|
|
1755
|
+
this.panInteractor.setWidthZoomLevel(newValue);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Change in 'pan-height-zoom-level' property.
|
|
1760
|
+
*/
|
|
1761
|
+
_panHeightZoomLevelChanged(newValue, oldValue) {
|
|
1762
|
+
if (this.panInteractor) {
|
|
1763
|
+
this.panInteractor.setHeightZoomLevel(newValue);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Change in 'pan-maximum-zoom-level' property.
|
|
1768
|
+
*/
|
|
1769
|
+
_panMaximumZoomLevelChanged(newValue, oldValue) {
|
|
1770
|
+
if (this.panInteractor) {
|
|
1771
|
+
this.panInteractor.setMaximumZoomLevel(newValue);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Reset the pan interactor.
|
|
1776
|
+
*/
|
|
1777
|
+
resetPan() {
|
|
1778
|
+
if (this.panInteractor) {
|
|
1779
|
+
this.panInteractor.reset();
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Change in 'renderer' property.
|
|
1784
|
+
*/
|
|
1785
|
+
_rendererChanged(newValue, oldValue) {
|
|
1786
|
+
if (oldValue === 'IMAGE') {
|
|
1787
|
+
this.sceneImage.src = 'data:,';
|
|
1788
|
+
this.renderRoot.querySelector('#dataVizDiv').removeChild(this.sceneImage);
|
|
1789
|
+
this.renderRoot.querySelector('#dataVizDiv').removeChild(this.sceneImageMap);
|
|
1790
|
+
}
|
|
1791
|
+
else if (oldValue === 'SVG') {
|
|
1792
|
+
var el = this.svgDiv;
|
|
1793
|
+
while (el.firstChild)
|
|
1794
|
+
el.removeChild(el.firstChild);
|
|
1795
|
+
this.renderRoot.querySelector('#dataVizDiv').removeChild(this.svgDiv);
|
|
1796
|
+
}
|
|
1797
|
+
else if (this.threeViewer) {
|
|
1798
|
+
this.threeViewer.clearGeometry();
|
|
1799
|
+
this.threeViewer.render();
|
|
1800
|
+
this.renderRoot.querySelector('#dataVizDiv').removeChild(this.threeViewer.domElement);
|
|
1801
|
+
}
|
|
1802
|
+
if (newValue === 'IMAGE') {
|
|
1803
|
+
if (this.sceneImage === undefined) {
|
|
1804
|
+
this.sceneImage = document.createElement("img");
|
|
1805
|
+
this.sceneImage.setAttribute("id", "sceneImage");
|
|
1806
|
+
this.sceneImage.setAttribute("usemap", "#sceneImageMap");
|
|
1807
|
+
this.sceneImageMap = document.createElement("map");
|
|
1808
|
+
this.sceneImageMap.setAttribute("id", "sceneImageMap");
|
|
1809
|
+
this.sceneImageMap.setAttribute("name", "sceneImageMap");
|
|
1810
|
+
}
|
|
1811
|
+
this.renderRoot.querySelector('#dataVizDiv').appendChild(this.sceneImage);
|
|
1812
|
+
this.renderRoot.querySelector('#dataVizDiv').appendChild(this.sceneImageMap);
|
|
1813
|
+
this.threeViewer = null;
|
|
1814
|
+
}
|
|
1815
|
+
else if (newValue === 'SVG') {
|
|
1816
|
+
if (this.svgDiv === undefined) {
|
|
1817
|
+
this.svgDiv = document.createElement("div");
|
|
1818
|
+
this.svgDiv.setAttribute("id", "svgDiv");
|
|
1819
|
+
}
|
|
1820
|
+
this.renderRoot.querySelector('#dataVizDiv').appendChild(this.svgDiv);
|
|
1821
|
+
this.threeViewer = null;
|
|
1822
|
+
}
|
|
1823
|
+
else {
|
|
1824
|
+
if (!this.threeViewer) {
|
|
1825
|
+
// Create ThreeJS viewer
|
|
1826
|
+
this.threeViewer = new Viewer();
|
|
1827
|
+
// Check if the user has requested a specific renderer
|
|
1828
|
+
var rendererId = 'avsDefaultWebGLRenderer';
|
|
1829
|
+
// if (this.rendererProperties.webGLRendererId !== undefined) {
|
|
1830
|
+
// rendererId = this.rendererProperties.webGLRendererId;
|
|
1831
|
+
// }
|
|
1832
|
+
// Search for renderer, if not found create one and save to the DOM
|
|
1833
|
+
var renderer = document.getElementById(rendererId);
|
|
1834
|
+
if (renderer === undefined || renderer === null) {
|
|
1835
|
+
renderer = new AvsRenderer();
|
|
1836
|
+
renderer.setAttribute('id', rendererId);
|
|
1837
|
+
document.body.appendChild(renderer);
|
|
1838
|
+
// console.log("create new webGL renderer = " + rendererId);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
// console.log("reference existing webGL renderer = " + rendererId);
|
|
1842
|
+
}
|
|
1843
|
+
this.threeViewer.setWebGLRenderer(renderer.webGLRenderer);
|
|
1844
|
+
this.animator = new Animator();
|
|
1845
|
+
this.threeViewer.setAnimator(this.animator);
|
|
1846
|
+
}
|
|
1847
|
+
this.renderRoot.querySelector('#dataVizDiv').appendChild(this.threeViewer.domElement);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Change in 'track-enable' property.
|
|
1852
|
+
*/
|
|
1853
|
+
_trackEnableChanged(newValue, oldValue) {
|
|
1854
|
+
if (newValue) {
|
|
1855
|
+
if (this.rectCanvas === undefined) {
|
|
1856
|
+
this.rectCanvas = document.createElement("canvas");
|
|
1857
|
+
this.rectCanvas.setAttribute("id", "rectCanvas");
|
|
1858
|
+
this.rectCtx = this.rectCanvas.getContext('2d');
|
|
1859
|
+
}
|
|
1860
|
+
this.renderRoot.appendChild(this.rectCanvas);
|
|
1861
|
+
}
|
|
1862
|
+
else {
|
|
1863
|
+
this.renderRoot.removeChild(this.rectCanvas);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Change in 'display-canvas' property.
|
|
1868
|
+
*/
|
|
1869
|
+
_displayCanvasChanged(newValue, oldValue) {
|
|
1870
|
+
if (this.threeViewer) {
|
|
1871
|
+
this.threeViewer.displayCanvas = newValue;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
setTooltipHTML(html) {
|
|
1875
|
+
this.renderRoot.querySelector('#tooltip').innerHTML = html;
|
|
1876
|
+
}
|
|
1877
|
+
showTooltip(clientX, clientY) {
|
|
1878
|
+
var tooltip = this.renderRoot.querySelector('#tooltip');
|
|
1879
|
+
var pos = this._calcTooltipPosition(tooltip, clientX, clientY);
|
|
1880
|
+
tooltip.style.left = pos.x + "px";
|
|
1881
|
+
tooltip.style.top = pos.y + "px";
|
|
1882
|
+
tooltip.style.opacity = "1";
|
|
1883
|
+
}
|
|
1884
|
+
hideTooltip() {
|
|
1885
|
+
var tooltip = this.renderRoot.querySelector('#tooltip');
|
|
1886
|
+
tooltip.style.opacity = "0";
|
|
1887
|
+
}
|
|
1888
|
+
_calcTooltipPosition(tooltip, clientX, clientY) {
|
|
1889
|
+
// Calculate the tooltip location based on 4 quadrants of the visible portion
|
|
1890
|
+
// of the visualization window
|
|
1891
|
+
var dataVizDiv = this.renderRoot.querySelector('#dataVizDiv');
|
|
1892
|
+
var offset = this._getOffset(dataVizDiv);
|
|
1893
|
+
var deltaTop = -Math.min(0, offset.top - window.pageYOffset);
|
|
1894
|
+
var deltaLeft = -Math.min(0, offset.left - window.pageXOffset);
|
|
1895
|
+
var deltaBottom = -Math.min(0, window.innerHeight - (dataVizDiv.offsetHeight + offset.top - window.pageYOffset));
|
|
1896
|
+
var deltaRight = -Math.min(0, window.innerWidth - (dataVizDiv.offsetWidth + offset.left - window.pageXOffset));
|
|
1897
|
+
var vizHeight = dataVizDiv.offsetHeight - deltaTop - deltaBottom;
|
|
1898
|
+
var vizWidth = dataVizDiv.offsetWidth - deltaLeft - deltaRight;
|
|
1899
|
+
var vizHalfX = vizWidth / 2 + deltaLeft;
|
|
1900
|
+
var vizHalfY = vizHeight / 2 + deltaTop;
|
|
1901
|
+
var toolPosition = { x: 0, y: 0 };
|
|
1902
|
+
if (clientX < vizHalfX) {
|
|
1903
|
+
var offst = (clientY < vizHalfY) ? 15 : 5;
|
|
1904
|
+
toolPosition.x = clientX + offst + dataVizDiv.offsetLeft;
|
|
1905
|
+
}
|
|
1906
|
+
else {
|
|
1907
|
+
toolPosition.x = clientX - 10 + dataVizDiv.offsetLeft - tooltip.offsetWidth;
|
|
1908
|
+
}
|
|
1909
|
+
if (clientY < vizHalfY) {
|
|
1910
|
+
toolPosition.y = clientY + 5 + dataVizDiv.offsetTop;
|
|
1911
|
+
}
|
|
1912
|
+
else {
|
|
1913
|
+
toolPosition.y = clientY - 10 + dataVizDiv.offsetTop - tooltip.offsetHeight;
|
|
1914
|
+
}
|
|
1915
|
+
return toolPosition;
|
|
1916
|
+
}
|
|
1917
|
+
_getOffset(dataVizDiv) {
|
|
1918
|
+
var rect = dataVizDiv.getBoundingClientRect(), scrollLeft = window.pageXOffset || document.documentElement.scrollLeft, scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
1919
|
+
return { top: rect.top + scrollTop, left: rect.left + scrollLeft };
|
|
1920
|
+
}
|
|
1921
|
+
};
|
|
1922
|
+
__decorate([
|
|
1923
|
+
property({ attribute: 'manual-update', type: Boolean })
|
|
1924
|
+
], AvsGoDataViz.prototype, "manualUpdate", void 0);
|
|
1925
|
+
__decorate([
|
|
1926
|
+
property({ attribute: 'display-canvas', type: Boolean })
|
|
1927
|
+
], AvsGoDataViz.prototype, "displayCanvas", void 0);
|
|
1928
|
+
__decorate([
|
|
1929
|
+
property()
|
|
1930
|
+
], AvsGoDataViz.prototype, "url", void 0);
|
|
1931
|
+
__decorate([
|
|
1932
|
+
property({ attribute: 'url-load-json-file', type: Boolean })
|
|
1933
|
+
], AvsGoDataViz.prototype, "urlLoadJsonFile", void 0);
|
|
1934
|
+
__decorate([
|
|
1935
|
+
property({ attribute: 'data-source-name' })
|
|
1936
|
+
], AvsGoDataViz.prototype, "dataSourceName", void 0);
|
|
1937
|
+
__decorate([
|
|
1938
|
+
property({ attribute: 'data-source-user-properties' })
|
|
1939
|
+
], AvsGoDataViz.prototype, "dataSourceUserProperties", void 0);
|
|
1940
|
+
__decorate([
|
|
1941
|
+
property({ attribute: 'scene-name' })
|
|
1942
|
+
], AvsGoDataViz.prototype, "sceneName", void 0);
|
|
1943
|
+
__decorate([
|
|
1944
|
+
property({ attribute: 'scene-user-properties' })
|
|
1945
|
+
], AvsGoDataViz.prototype, "sceneUserProperties", void 0);
|
|
1946
|
+
__decorate([
|
|
1947
|
+
property({ attribute: 'renderer-name' })
|
|
1948
|
+
], AvsGoDataViz.prototype, "rendererName", void 0);
|
|
1949
|
+
__decorate([
|
|
1950
|
+
property({ attribute: 'renderer-user-properties' })
|
|
1951
|
+
], AvsGoDataViz.prototype, "rendererUserProperties", void 0);
|
|
1952
|
+
__decorate([
|
|
1953
|
+
property()
|
|
1954
|
+
], AvsGoDataViz.prototype, "renderer", void 0);
|
|
1955
|
+
__decorate([
|
|
1956
|
+
property({ attribute: 'stream-enable', type: Boolean })
|
|
1957
|
+
], AvsGoDataViz.prototype, "streamEnable", void 0);
|
|
1958
|
+
__decorate([
|
|
1959
|
+
property({ attribute: 'stream-chunk-size-first' })
|
|
1960
|
+
], AvsGoDataViz.prototype, "streamChunkSizeFirst", void 0);
|
|
1961
|
+
__decorate([
|
|
1962
|
+
property({ attribute: 'stream-chunk-size' })
|
|
1963
|
+
], AvsGoDataViz.prototype, "streamChunkSize", void 0);
|
|
1964
|
+
__decorate([
|
|
1965
|
+
property({ attribute: 'theme-name' })
|
|
1966
|
+
], AvsGoDataViz.prototype, "themeName", void 0);
|
|
1967
|
+
__decorate([
|
|
1968
|
+
property({ attribute: 'resize-threshold' })
|
|
1969
|
+
], AvsGoDataViz.prototype, "resizeThreshold", void 0);
|
|
1970
|
+
__decorate([
|
|
1971
|
+
property({ attribute: 'pointer-timeout' })
|
|
1972
|
+
], AvsGoDataViz.prototype, "pointerTimeout", void 0);
|
|
1973
|
+
__decorate([
|
|
1974
|
+
property({ attribute: 'tap-enable', type: Boolean })
|
|
1975
|
+
], AvsGoDataViz.prototype, "tapEnable", void 0);
|
|
1976
|
+
__decorate([
|
|
1977
|
+
property({ attribute: 'tap-level' })
|
|
1978
|
+
], AvsGoDataViz.prototype, "tapLevel", void 0);
|
|
1979
|
+
__decorate([
|
|
1980
|
+
property({ attribute: 'tap-depth' })
|
|
1981
|
+
], AvsGoDataViz.prototype, "tapDepth", void 0);
|
|
1982
|
+
__decorate([
|
|
1983
|
+
property({ attribute: 'tap-highlight-enable', type: Boolean })
|
|
1984
|
+
], AvsGoDataViz.prototype, "tapHighlightEnable", void 0);
|
|
1985
|
+
__decorate([
|
|
1986
|
+
property({ attribute: 'tap-highlight-color' })
|
|
1987
|
+
], AvsGoDataViz.prototype, "tapHighlightColor", void 0);
|
|
1988
|
+
__decorate([
|
|
1989
|
+
property({ attribute: 'tap-highlight-layer-enable', type: Boolean })
|
|
1990
|
+
], AvsGoDataViz.prototype, "tapHighlightLayerEnable", void 0);
|
|
1991
|
+
__decorate([
|
|
1992
|
+
property({ attribute: 'tap-process-event-on-client', type: Boolean })
|
|
1993
|
+
], AvsGoDataViz.prototype, "tapProcessEventOnClient", void 0);
|
|
1994
|
+
__decorate([
|
|
1995
|
+
property({ attribute: 'track-enable', type: Boolean })
|
|
1996
|
+
], AvsGoDataViz.prototype, "trackEnable", void 0);
|
|
1997
|
+
__decorate([
|
|
1998
|
+
property({ attribute: 'track-level' })
|
|
1999
|
+
], AvsGoDataViz.prototype, "trackLevel", void 0);
|
|
2000
|
+
__decorate([
|
|
2001
|
+
property({ attribute: 'track-depth' })
|
|
2002
|
+
], AvsGoDataViz.prototype, "trackDepth", void 0);
|
|
2003
|
+
__decorate([
|
|
2004
|
+
property({ attribute: 'track-highlight-enable', type: Boolean })
|
|
2005
|
+
], AvsGoDataViz.prototype, "trackHighlightEnable", void 0);
|
|
2006
|
+
__decorate([
|
|
2007
|
+
property({ attribute: 'track-highlight-color' })
|
|
2008
|
+
], AvsGoDataViz.prototype, "trackHighlightColor", void 0);
|
|
2009
|
+
__decorate([
|
|
2010
|
+
property({ attribute: 'track-highlight-layer-enable', type: Boolean })
|
|
2011
|
+
], AvsGoDataViz.prototype, "trackHighlightLayerEnable", void 0);
|
|
2012
|
+
__decorate([
|
|
2013
|
+
property({ attribute: 'track-process-event-on-client', type: Boolean })
|
|
2014
|
+
], AvsGoDataViz.prototype, "trackProcessEventOnClient", void 0);
|
|
2015
|
+
__decorate([
|
|
2016
|
+
property({ attribute: 'hover-enable', type: Boolean })
|
|
2017
|
+
], AvsGoDataViz.prototype, "hoverEnable", void 0);
|
|
2018
|
+
__decorate([
|
|
2019
|
+
property({ attribute: 'hover-level' })
|
|
2020
|
+
], AvsGoDataViz.prototype, "hoverLevel", void 0);
|
|
2021
|
+
__decorate([
|
|
2022
|
+
property({ attribute: 'hover-depth' })
|
|
2023
|
+
], AvsGoDataViz.prototype, "hoverDepth", void 0);
|
|
2024
|
+
__decorate([
|
|
2025
|
+
property({ attribute: 'hover-highlight-enable', type: Boolean })
|
|
2026
|
+
], AvsGoDataViz.prototype, "hoverHighlightEnable", void 0);
|
|
2027
|
+
__decorate([
|
|
2028
|
+
property({ attribute: 'hover-highlight-color' })
|
|
2029
|
+
], AvsGoDataViz.prototype, "hoverHighlightColor", void 0);
|
|
2030
|
+
__decorate([
|
|
2031
|
+
property({ attribute: 'hover-highlight-layer-enable', type: Boolean })
|
|
2032
|
+
], AvsGoDataViz.prototype, "hoverHighlightLayerEnable", void 0);
|
|
2033
|
+
__decorate([
|
|
2034
|
+
property({ attribute: 'transform-enable', type: Boolean })
|
|
2035
|
+
], AvsGoDataViz.prototype, "transformEnable", void 0);
|
|
2036
|
+
__decorate([
|
|
2037
|
+
property({ attribute: 'transform-client-only', type: Boolean })
|
|
2038
|
+
], AvsGoDataViz.prototype, "transformClientOnly", void 0);
|
|
2039
|
+
__decorate([
|
|
2040
|
+
property({ attribute: 'transform-rotate-disable', type: Boolean })
|
|
2041
|
+
], AvsGoDataViz.prototype, "transformRotateDisable", void 0);
|
|
2042
|
+
__decorate([
|
|
2043
|
+
property({ attribute: 'transform-zoom-disable', type: Boolean })
|
|
2044
|
+
], AvsGoDataViz.prototype, "transformZoomDisable", void 0);
|
|
2045
|
+
__decorate([
|
|
2046
|
+
property({ attribute: 'transform-pan-disable', type: Boolean })
|
|
2047
|
+
], AvsGoDataViz.prototype, "transformPanDisable", void 0);
|
|
2048
|
+
__decorate([
|
|
2049
|
+
property({ attribute: 'transform-twist-angle' })
|
|
2050
|
+
], AvsGoDataViz.prototype, "transformTwistAngle", void 0);
|
|
2051
|
+
__decorate([
|
|
2052
|
+
property({ attribute: 'transform-tilt-angle' })
|
|
2053
|
+
], AvsGoDataViz.prototype, "transformTiltAngle", void 0);
|
|
2054
|
+
__decorate([
|
|
2055
|
+
property({ attribute: 'transform-scale' })
|
|
2056
|
+
], AvsGoDataViz.prototype, "transformScale", void 0);
|
|
2057
|
+
__decorate([
|
|
2058
|
+
property({ attribute: 'motion-capture' })
|
|
2059
|
+
], AvsGoDataViz.prototype, "motionCapture", void 0);
|
|
2060
|
+
__decorate([
|
|
2061
|
+
property({ attribute: 'zoom-rectangle-enable', type: Boolean })
|
|
2062
|
+
], AvsGoDataViz.prototype, "zoomRectangleEnable", void 0);
|
|
2063
|
+
__decorate([
|
|
2064
|
+
property({ attribute: 'pan-enable', type: Boolean })
|
|
2065
|
+
], AvsGoDataViz.prototype, "panEnable", void 0);
|
|
2066
|
+
__decorate([
|
|
2067
|
+
property({ attribute: 'pan-zoom-enable', type: Boolean })
|
|
2068
|
+
], AvsGoDataViz.prototype, "panZoomEnable", void 0);
|
|
2069
|
+
__decorate([
|
|
2070
|
+
property({ attribute: 'pan-width-zoom-level' })
|
|
2071
|
+
], AvsGoDataViz.prototype, "panWidthZoomLevel", void 0);
|
|
2072
|
+
__decorate([
|
|
2073
|
+
property({ attribute: 'pan-height-zoom-level' })
|
|
2074
|
+
], AvsGoDataViz.prototype, "panHeightZoomLevel", void 0);
|
|
2075
|
+
__decorate([
|
|
2076
|
+
property({ attribute: 'pan-maximum-zoom-level' })
|
|
2077
|
+
], AvsGoDataViz.prototype, "panMaximumZoomLevel", void 0);
|
|
2078
|
+
__decorate([
|
|
2079
|
+
property({ attribute: 'animated-glyphs-visible', type: Boolean })
|
|
2080
|
+
], AvsGoDataViz.prototype, "animatedGlyphsVisible", void 0);
|
|
2081
|
+
__decorate([
|
|
2082
|
+
property({ attribute: 'animated-glyphs-enable', type: Boolean })
|
|
2083
|
+
], AvsGoDataViz.prototype, "animatedGlyphsEnable", void 0);
|
|
2084
|
+
__decorate([
|
|
2085
|
+
property({ attribute: 'motion-capture-controls-enable', type: Boolean })
|
|
2086
|
+
], AvsGoDataViz.prototype, "motionCaptureControlsEnable", void 0);
|
|
2087
|
+
AvsGoDataViz = __decorate([
|
|
2088
|
+
customElement('avs-go-dataviz')
|
|
2089
|
+
], AvsGoDataViz);
|
|
2090
|
+
export { AvsGoDataViz };
|