修改大屏

master
夜笙歌 6 months ago
parent d07a5ffe75
commit c401c479c3

@ -8,11 +8,12 @@ import * as THREE from 'three';
import {OBJLoader} from 'three/examples/jsm/loaders/OBJLoader.js';
import {MTLLoader} from 'three/examples/jsm/loaders/MTLLoader.js';
import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls.js';
import {CSS2DRenderer} from "three/examples/jsm/renderers/CSS2DRenderer";
const vw = (document.documentElement.clientWidth || document.body.clientWidth) / 100
let a = 0
let aa = true
let lastModel = null
export default {
name: 'Model',
components: {},
@ -104,6 +105,21 @@ export default {
animate();
const labelRenderer = new CSS2DRenderer();
labelRenderer.setSize(window.innerWidth, window.innerHeight);
labelRenderer.domElement.style.position = 'absolute';
labelRenderer.domElement.style.top = 0;
document.body.appendChild(labelRenderer.domElement);
// CSS2DObject
const label = document.createElement('div');
label.style.color = 'red';
label.innerHTML = '这是提示窗口';
const labelObject = new CSS2DObject(label);
labelObject.position.set(0, 1, 0); //
scene.add(labelObject);
// raycaster
var raycaster = new THREE.Raycaster();
@ -112,7 +128,7 @@ export default {
var mouse = new THREE.Vector2();
//
document.addEventListener('click', function (event) {
document.addEventListener('dblclick', function (event) {
//
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
@ -128,6 +144,11 @@ export default {
//
var obj = intersects[0].object;
console.log('Clicked object:', obj);
outlineObj(obj.parent)
// obj.parent.children.forEach(e => {
// e.material.color.set(0xff0000);
// })
// obj.material.color.set(0xff0000);
alert(obj.parent?.name || obj.name)
//
}

Loading…
Cancel
Save