952 三角面2.00 × 0.20 × 2.00 m
在代码中使用
在编辑器中改编spawn-pad.js · 152 行
自包含的 ES 模块,仅依赖 three。调用工厂函数,然后把返回的 group 添加到场景中。
/**
* Spawn Pad — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 952 · Size (W × H × D): 2.00 × 0.20 × 2.00 m
*
* Usage:
* import { createSpawnPad } from './spawn-pad.js';
*
* const model = createSpawnPad();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
// Revolve a 2D profile [[radius, y], ...] around the Y axis.
function lathe(points, segments, phiStart = 0, phiLength = Math.PI * 2) {
return new THREE.LatheGeometry(points.map(([x, y]) => new THREE.Vector2(x, y)), segments, phiStart, phiLength);
}
// Extrude a 2D outline along Z (centered). bevel = [thickness, size, segments].
function extrude(outline, depth, holes = [], bevel = null) {
const shape = new THREE.Shape(outline.map(([x, y]) => new THREE.Vector2(x, y)));
for (const hole of holes) shape.holes.push(new THREE.Path(hole.map(([x, y]) => new THREE.Vector2(x, y))));
const options = bevel
? { depth, bevelEnabled: true, bevelThickness: bevel[0], bevelSize: bevel[1], bevelSegments: bevel[2] }
: { depth, bevelEnabled: false };
return new THREE.ExtrudeGeometry(shape, options).translate(0, 0, -depth / 2);
}
export function createSpawnPad() {
const root = new THREE.Group();
root.name = 'SpawnPad';
// Materials
const baseMat = new THREE.MeshStandardMaterial({ name: 'base', color: 0x2d3341, roughness: 0.55, metalness: 0.35, flatShading: true });
const plateMat = new THREE.MeshStandardMaterial({ name: 'plate', color: 0x485267, roughness: 0.5, metalness: 0.3, flatShading: true });
const glowMat = new THREE.MeshStandardMaterial({ name: 'glow', color: 0x68d6ff, roughness: 0.3, emissive: 0x35c8ff, flatShading: true });
const dimMat = new THREE.MeshStandardMaterial({ name: 'dim', color: 0x297da2, roughness: 0.4, emissive: 0x35c8ff, emissiveIntensity: 0.3, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.16, 0.03, 0.035);
const extrudeGeo = extrude([[0, -0.07], [0.16, 0.09], [0.16, 0.17], [0, 0.01], [-0.16, 0.17], [-0.16, 0.09]], 0.03);
// Parts
const spawnPad = new THREE.Group();
spawnPad.name = 'spawnPad';
root.add(spawnPad);
const base = new THREE.Mesh(lathe([[0, 0], [1, 0], [1, 0.09], [0.93, 0.15], [0, 0.15]], 28), baseMat);
base.name = 'base';
spawnPad.add(base);
const plate = new THREE.Mesh(lathe([[0, 0.14], [0.86, 0.14], [0.86, 0.175], [0, 0.175]], 28), plateMat);
plate.name = 'plate';
spawnPad.add(plate);
const glowRing = new THREE.Mesh(lathe([[0.8, 0.17], [0.8, 0.195], [0.72, 0.195], [0.72, 0.17]], 28), glowMat);
glowRing.name = 'glowRing';
spawnPad.add(glowRing);
const light1 = new THREE.Mesh(boxGeo, dimMat);
light1.name = 'light1';
light1.position.set(0.895, 0.155, 0);
light1.rotation.set(0, deg(-90), 0);
spawnPad.add(light1);
const light2 = new THREE.Mesh(boxGeo, dimMat);
light2.name = 'light2';
light2.position.set(0.7751, 0.155, -0.4475);
light2.rotation.set(0, deg(-60), 0);
spawnPad.add(light2);
const light3 = new THREE.Mesh(boxGeo, dimMat);
light3.name = 'light3';
light3.position.set(0.4475, 0.155, -0.7751);
light3.rotation.set(0, deg(-30), 0);
spawnPad.add(light3);
const light4 = new THREE.Mesh(boxGeo, dimMat);
light4.name = 'light4';
light4.position.set(0, 0.155, -0.895);
spawnPad.add(light4);
const light5 = new THREE.Mesh(boxGeo, dimMat);
light5.name = 'light5';
light5.position.set(-0.4475, 0.155, -0.7751);
light5.rotation.set(0, deg(30), 0);
spawnPad.add(light5);
const light6 = new THREE.Mesh(boxGeo, dimMat);
light6.name = 'light6';
light6.position.set(-0.7751, 0.155, -0.4475);
light6.rotation.set(0, deg(60), 0);
spawnPad.add(light6);
const light7 = new THREE.Mesh(boxGeo, dimMat);
light7.name = 'light7';
light7.position.set(-0.895, 0.155, 0);
light7.rotation.set(0, deg(90), 0);
spawnPad.add(light7);
const light8 = new THREE.Mesh(boxGeo, dimMat);
light8.name = 'light8';
light8.position.set(-0.7751, 0.155, 0.4475);
light8.rotation.set(0, deg(120), 0);
spawnPad.add(light8);
const light9 = new THREE.Mesh(boxGeo, dimMat);
light9.name = 'light9';
light9.position.set(-0.4475, 0.155, 0.7751);
light9.rotation.set(0, deg(150), 0);
spawnPad.add(light9);
const light10 = new THREE.Mesh(boxGeo, dimMat);
light10.name = 'light10';
light10.position.set(0, 0.155, 0.895);
light10.rotation.set(0, deg(180), 0);
spawnPad.add(light10);
const light11 = new THREE.Mesh(boxGeo, dimMat);
light11.name = 'light11';
light11.position.set(0.4475, 0.155, 0.7751);
light11.rotation.set(0, deg(210), 0);
spawnPad.add(light11);
const light12 = new THREE.Mesh(boxGeo, dimMat);
light12.name = 'light12';
light12.position.set(0.7751, 0.155, 0.4475);
light12.rotation.set(0, deg(240), 0);
spawnPad.add(light12);
const arrow1 = new THREE.Mesh(extrudeGeo, glowMat);
arrow1.name = 'arrow1';
arrow1.position.set(0.3536, 0.175, -0.3536);
arrow1.rotation.set(deg(-90), 0, deg(-45));
spawnPad.add(arrow1);
const arrow2 = new THREE.Mesh(extrudeGeo, glowMat);
arrow2.name = 'arrow2';
arrow2.position.set(-0.3536, 0.175, -0.3536);
arrow2.rotation.set(deg(-90), 0, deg(45));
spawnPad.add(arrow2);
const arrow3 = new THREE.Mesh(extrudeGeo, glowMat);
arrow3.name = 'arrow3';
arrow3.position.set(-0.3536, 0.175, 0.3536);
arrow3.rotation.set(deg(-90), 0, deg(135));
spawnPad.add(arrow3);
const arrow4 = new THREE.Mesh(extrudeGeo, glowMat);
arrow4.name = 'arrow4';
arrow4.position.set(0.3536, 0.175, 0.3536);
arrow4.rotation.set(deg(-90), 0, deg(225));
spawnPad.add(arrow4);
const coreRing = new THREE.Mesh(lathe([[0.2, 0.17], [0.2, 0.19], [0.13, 0.19], [0.13, 0.17]], 28), dimMat);
coreRing.name = 'coreRing';
spawnPad.add(coreRing);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createSpawnPad;
评分与评论
0 条评论
暂无评论。分享一下你是如何使用这个模型的,或者有哪些可以改进的地方。
相关模型
同一分类或相似标签









