2021-03-29 18:27:34 +08:00
|
|
|
import * as THREE from '../../node_modules/three/src/Three';
|
|
|
|
|
2021-03-31 07:20:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
const _vec2 = new THREE.Vector2()
|
|
|
|
const _vec3 = new THREE.Vector3()
|
|
|
|
|
|
|
|
|
|
|
|
const raycaster = new THREE.Raycaster();
|
|
|
|
raycaster.params.Line.threshold = 0.8;
|
|
|
|
raycaster.params.Points.threshold = 1.5;
|
|
|
|
|
|
|
|
|
|
|
|
const color = {
|
|
|
|
dark1: 0x555555,
|
|
|
|
hover: 0x00ff00,
|
|
|
|
extrude: 0x156289,
|
|
|
|
emissive: 0x072534
|
|
|
|
}
|
|
|
|
|
2021-03-29 18:27:34 +08:00
|
|
|
const lineMaterial = new THREE.LineBasicMaterial({
|
|
|
|
linewidth: 2,
|
2021-03-31 07:20:24 +08:00
|
|
|
color: color.dark1,
|
2021-03-29 18:27:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const pointMaterial = new THREE.PointsMaterial({
|
2021-03-31 07:20:24 +08:00
|
|
|
color: color.dark1,
|
2021-03-29 18:27:34 +08:00
|
|
|
size: 4,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-31 07:20:24 +08:00
|
|
|
|
|
|
|
const ptObj = (n) => new THREE.Points(
|
|
|
|
new THREE.BufferGeometry().setAttribute('position',
|
|
|
|
new THREE.Float32BufferAttribute(n || 3, 3)
|
|
|
|
),
|
|
|
|
pointMaterial.clone()
|
|
|
|
);
|
|
|
|
|
|
|
|
const lineObj = (n=1) => new THREE.Line(
|
|
|
|
new THREE.BufferGeometry().setAttribute('position',
|
|
|
|
new THREE.Float32BufferAttribute(3 * (n+1), 3)
|
|
|
|
),
|
|
|
|
lineMaterial.clone()
|
|
|
|
);
|
2021-03-29 18:27:34 +08:00
|
|
|
|
|
|
|
|
2021-03-31 07:20:24 +08:00
|
|
|
export { lineMaterial, pointMaterial, _vec2, _vec3, raycaster, color, ptObj, lineObj }
|