1234567891011121314151617181920 |
- export class TopologyHandler extends BaseDataHandler {
- parse(data) {
- // 1. 根据拓扑数据生成颜色材质
- const material = createMaterial({
- type: 'meshPhong',
- colorMap: data.colorMap
- })
-
- // 2. 构建几何体
- const geometry = new THREE.BufferGeometry()
- geometry.setAttribute('position', new Float32BufferAttribute(data.vertices, 3))
-
- // 3. 生成可交互对象
- const mesh = new THREE.Mesh(geometry, material)
- mesh.userData = { originalData: data }
-
- this.scene.add(mesh)
- this.objectMap.set(data.id, mesh)
- }
- }
|