Refine ship orders and viewer controls
This commit is contained in:
@@ -64,6 +64,47 @@ export function createResourceDepositMesh(deposit: ResourceDepositSnapshot, node
|
||||
return createSceneNode(mesh);
|
||||
}
|
||||
|
||||
export function createLocalResourceNodeMesh(node: ResourceNodeSnapshot): SceneNode {
|
||||
const isGas = node.sourceKind === "gas-cloud" || node.itemId === "gas";
|
||||
const oreRatio = node.maxOre <= 0.01 ? 0 : node.oreRemaining / node.maxOre;
|
||||
const radius = isGas
|
||||
? 120 + (oreRatio * 30)
|
||||
: 55 + (oreRatio * 20);
|
||||
const mesh = new THREE.Mesh(
|
||||
new THREE.SphereGeometry(radius, isGas ? 18 : 16, isGas ? 18 : 16),
|
||||
new THREE.MeshStandardMaterial({
|
||||
color: isGas ? 0x7fd6ff : 0xb28b59,
|
||||
roughness: isGas ? 0.4 : 0.92,
|
||||
metalness: isGas ? 0.06 : 0.08,
|
||||
transparent: isGas,
|
||||
opacity: isGas ? 0.5 : 1,
|
||||
emissive: new THREE.Color(isGas ? 0x7fd6ff : 0xb28b59).multiplyScalar(isGas ? 0.18 : 0.03),
|
||||
}),
|
||||
);
|
||||
return createSceneNode(mesh);
|
||||
}
|
||||
|
||||
export function createLocalResourceDepositMesh(deposit: ResourceDepositSnapshot, node: ResourceNodeSnapshot): SceneNode {
|
||||
const isGas = node.sourceKind === "gas-cloud" || node.itemId === "gas";
|
||||
const oreRatio = deposit.maxOre <= 0.01 ? 0 : deposit.oreRemaining / deposit.maxOre;
|
||||
const radius = isGas
|
||||
? 8 + (oreRatio * 4)
|
||||
: 3 + (oreRatio * 4);
|
||||
const mesh = new THREE.Mesh(
|
||||
new THREE.SphereGeometry(radius, 12, 12),
|
||||
new THREE.MeshStandardMaterial({
|
||||
color: isGas ? 0x92deff : 0xd0ad77,
|
||||
roughness: isGas ? 0.36 : 0.95,
|
||||
metalness: isGas ? 0.04 : 0.02,
|
||||
transparent: isGas,
|
||||
opacity: isGas ? 0.58 : 1,
|
||||
emissive: new THREE.Color(isGas ? 0x92deff : 0xd0ad77).multiplyScalar(isGas ? 0.16 : 0.025),
|
||||
}),
|
||||
);
|
||||
mesh.position.copy(toThreeVector(deposit.localPosition));
|
||||
return createSceneNode(mesh);
|
||||
}
|
||||
|
||||
export function createCelestialMesh(node: CelestialSnapshot, celestialColor: (kind: string) => string): SceneNode {
|
||||
const color = celestialColor(node.kind);
|
||||
return createSceneNode(new THREE.Mesh(
|
||||
@@ -229,17 +270,31 @@ export function createStationMesh(station: StationSnapshot): SceneNode {
|
||||
}
|
||||
|
||||
export function createShipMesh(ship: ShipSnapshot, size: number, length: number, color: string): SceneNode {
|
||||
const geometry = new THREE.ConeGeometry(size, length, 7);
|
||||
geometry.rotateX(Math.PI / 2);
|
||||
const mesh = new THREE.Mesh(
|
||||
geometry,
|
||||
new THREE.MeshStandardMaterial({
|
||||
color,
|
||||
emissive: new THREE.Color(color).multiplyScalar(0.18),
|
||||
}),
|
||||
const root = new THREE.Group();
|
||||
const material = new THREE.MeshStandardMaterial({
|
||||
color,
|
||||
emissive: new THREE.Color(color).multiplyScalar(0.28),
|
||||
});
|
||||
|
||||
const bodyRadius = Math.max(size * 0.48, 2.4);
|
||||
const bodyLength = Math.max(length - (bodyRadius * 1.8), bodyRadius * 1.2);
|
||||
const body = new THREE.Mesh(
|
||||
new THREE.CapsuleGeometry(bodyRadius, bodyLength, 6, 12),
|
||||
material,
|
||||
);
|
||||
mesh.position.copy(toThreeVector(ship.localPosition));
|
||||
return createSceneNode(mesh);
|
||||
body.rotation.x = Math.PI / 2;
|
||||
root.add(body);
|
||||
|
||||
const nose = new THREE.Mesh(
|
||||
new THREE.ConeGeometry(Math.max(bodyRadius * 0.72, 1.8), Math.max(bodyRadius * 1.4, 3.2), 8),
|
||||
material,
|
||||
);
|
||||
nose.rotation.x = Math.PI / 2;
|
||||
nose.position.z = (bodyLength * 0.5) + (bodyRadius * 0.55);
|
||||
root.add(nose);
|
||||
|
||||
root.position.copy(toThreeVector(ship.localPosition));
|
||||
return createSceneNode(root);
|
||||
}
|
||||
|
||||
function createStarGlowTexture(documentRef: Document): THREE.CanvasTexture {
|
||||
|
||||
Reference in New Issue
Block a user