|
@@ -1,13 +1,10 @@
|
|
|
import * as THREE from 'three';
|
|
|
-import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer.js';
|
|
|
-// import * as dat from 'dat.gui';
|
|
|
-// const gui = new dat.GUI();
|
|
|
-// gui.domElement.style = 'position:absolute;top:100px;left:10px;z-index:99999999999999';
|
|
|
+import { CSS3DObject, CSS3DSprite } from 'three/examples/jsm/renderers/CSS3DRenderer.js';
|
|
|
+import { modelMonitorTags } from './gasPump.data';
|
|
|
|
|
|
class gasPumpUnder {
|
|
|
model;
|
|
|
modelName = 'gas-pump-underground';
|
|
|
- // modelName = 'gasPumpUnder';gas-pump-underground
|
|
|
group: THREE.Object3D | null = null;
|
|
|
|
|
|
constructor(model) {
|
|
@@ -19,34 +16,39 @@ class gasPumpUnder {
|
|
|
directionalLight.position.set(-48, 107, 36);
|
|
|
this.group?.add(directionalLight);
|
|
|
directionalLight.target = this.group as THREE.Object3D;
|
|
|
-
|
|
|
- // gui.add(directionalLight.position, 'x', -500, 800);
|
|
|
- // gui.add(directionalLight.position, 'y', -500, 800);
|
|
|
- // gui.add(directionalLight.position, 'z', -500, 800);
|
|
|
-
|
|
|
- // const pointLight2 = new THREE.PointLight(0xffffff, 2, 500);
|
|
|
- // pointLight2.position.set(-113, 29, 10);
|
|
|
- // // light2.castShadow = true
|
|
|
- // pointLight2.shadow.bias = -0.05;
|
|
|
- // this.group?.add(pointLight2);
|
|
|
-
|
|
|
- // gui.add(pointLight2.position, 'x', -500, 500);
|
|
|
- // gui.add(pointLight2.position, 'y', -500, 500);
|
|
|
- // gui.add(pointLight2.position, 'z', -500, 500);
|
|
|
}
|
|
|
|
|
|
+ // addCssText = () => {
|
|
|
+ // if (!this.group) return;
|
|
|
+ // if (!this.group.getObjectByName('text1')) {
|
|
|
+ // const element = document.getElementById('FlowSensor') as HTMLElement;
|
|
|
+ // if (element) {
|
|
|
+ // const parentElement = document.getElementById('gas3DCSS') as HTMLElement;
|
|
|
+ // parentElement.appendChild(element);
|
|
|
+ // const fanLocalCSS3D = new CSS3DObject(element);
|
|
|
+ // fanLocalCSS3D.name = 'text1';
|
|
|
+ // fanLocalCSS3D.scale.set(0.007, 0.007, 0.007);
|
|
|
+ // fanLocalCSS3D.position.set(0, 1.6, 0);
|
|
|
+ // this.group.add(fanLocalCSS3D);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+
|
|
|
addCssText = () => {
|
|
|
if (!this.group) return;
|
|
|
- if (!this.group.getObjectByName('text1')) {
|
|
|
- const element = document.getElementById('FlowSensor') as HTMLElement;
|
|
|
- if (element) {
|
|
|
- const parentElement = document.getElementById('gas3DCSS') as HTMLElement;
|
|
|
- parentElement.appendChild(element);
|
|
|
- const fanLocalCSS3D = new CSS3DObject(element);
|
|
|
- fanLocalCSS3D.name = 'text1';
|
|
|
- fanLocalCSS3D.scale.set(0.007, 0.007, 0.007);
|
|
|
- fanLocalCSS3D.position.set(0, 1.6, 0);
|
|
|
- this.group.add(fanLocalCSS3D);
|
|
|
+ const parentElement = document.getElementById('gas3DCSS') as HTMLElement;
|
|
|
+ for (let i = 0; i < modelMonitorTags.length; i++) {
|
|
|
+ const tag = modelMonitorTags[i];
|
|
|
+ if (!this.group.getObjectByName(tag.domId)) {
|
|
|
+ const element = document.getElementById(tag.domId) as HTMLElement;
|
|
|
+ if (element) {
|
|
|
+ parentElement.appendChild(element);
|
|
|
+ const fanLocalCSS3D = new CSS3DSprite(element);
|
|
|
+ fanLocalCSS3D.name = tag.domId;
|
|
|
+ fanLocalCSS3D.scale.set(0.009, 0.009, 0.009);
|
|
|
+ fanLocalCSS3D.position.set(tag.position[0], tag.position[1], tag.position[2]);
|
|
|
+ this.group.add(fanLocalCSS3D);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|