Spaces:
Running
Running
File size: 8,760 Bytes
926eeea 033fbe6 926eeea 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 c50b518 033fbe6 926eeea ccc8baf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Infinite World</title>
<style>
body { margin:0; overflow:hidden; }
canvas { display:block; }
</style>
<script type="module">
import * as THREE from 'three';
// β¦ your existing three.js init, camera, lights, renderer, controls β¦
// βββ Primitive helpers ββββββββββββββββββββββββββββββββββββββββββββββββββ
function createBox({width, height, depth, materialProps, position}) {
const geom = new THREE.BoxGeometry(width, height, depth);
const mat = new THREE.MeshStandardMaterial(materialProps);
const mesh = new THREE.Mesh(geom, mat);
mesh.position.copy(position);
return mesh;
}
// β¦ any other helpers like createPlane(), createSplineTube(), createParticles() β¦
// βββ Existing simple creators βββββββββββββββββββββββββββββββββββββββββββ
// function createSimpleHouse(...) { β¦ }
// function createTree(...) { β¦ }
// function createRock(...) { β¦ }
// function createFencePost(...) { β¦ }
// βββ 1. Cyberpunk City Builder Kit ββββββββββββββββββββββββββββββββββββββββ
function createCyberpunkWallPanel({
width=2, height=3, depth=0.2,
baseMaterial={ color:0x555555, metalness:0.8, roughness:0.4 },
trimMaterial={ emissive:0x00ffff, emissiveIntensity:1.2 },
windowCutouts=true, doorCutouts=false,
position=new THREE.Vector3()
}) {
const panel = createBox({ width, height, depth, materialProps: baseMaterial, position });
// trim
const trim = createBox({
width: width * 0.1, height: height, depth: depth + 0.01,
materialProps: trimMaterial,
position: position.clone().add(new THREE.Vector3(width/2 + 0.05, 0, 0))
});
panel.add(trim);
// TODO: boolean cutouts for windows/doors
return panel;
}
function createRooftopACUnit({
width=1, height=0.5, depth=1,
materialProps={ color:0x777777, roughness:0.7, metalness:0.3 },
position=new THREE.Vector3()
}) {
const unit = createBox({ width, height, depth, materialProps, position });
// grill detail, pipes, etc.
return unit;
}
function createHolographicWindowDisplay({
width=1.5, height=1, position=new THREE.Vector3()
}) {
const planeMat = new THREE.MeshBasicMaterial({
color: 0xffffff, transparent:true, opacity:0.6
});
const geom = new THREE.PlaneGeometry(width, height);
const display = new THREE.Mesh(geom, planeMat);
display.position.copy(position);
// animate emissive shader parameter hereβ¦
return display;
}
function createGreebleSet({
count=10, scale=0.2, position=new THREE.Vector3()
}) {
const group = new THREE.Group();
for(let i=0; i<count; i++){
const x = (Math.random()-0.5)*2;
const y = (Math.random()-0.5)*2;
const z = (Math.random()-0.5)*0.2;
const pebble = createBox({
width: scale, height: scale, depth: scale,
materialProps:{ color:0x444444, roughness:0.6, metalness:0.4 },
position: position.clone().add(new THREE.Vector3(x,y,z))
});
group.add(pebble);
}
return group;
}
function createCyberpunkKit(position=new THREE.Vector3()) {
const kit = new THREE.Group();
kit.add(createCyberpunkWallPanel({ position: position.clone() }));
kit.add(createRooftopACUnit({ position: position.clone().add(new THREE.Vector3(3,0,0)) }));
kit.add(createHolographicWindowDisplay({ position: position.clone().add(new THREE.Vector3(6,1,0)) }));
kit.add(createGreebleSet({ position: position.clone().add(new THREE.Vector3(9,0,0)) }));
scene.add(kit);
}
// βββ 2. POLYGON β Fantasy Kingdom Pack βββββββββββββββββββββββββββββββββββ
function createKingFigure({
scale=1, materialProps={ color:0xffd700, metalness:0.9, roughness:0.2 },
position=new THREE.Vector3()
}) {
// placeholder lowβpoly silhouette
const geom = new THREE.CylinderGeometry(0.3*scale, 0.5*scale, 1.8*scale, 6);
const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial(materialProps));
mesh.position.copy(position);
return mesh;
}
function createSoldierFigure({ position=new THREE.Vector3() }) { /*β¦*/ }
function createMageFigure({ position=new THREE.Vector3() }) { /*β¦*/ }
function createFantasyKingdomPack(position=new THREE.Vector3()) {
const pack = new THREE.Group();
pack.add(createKingFigure({ position }));
pack.add(createSoldierFigure({ position: position.clone().add(new THREE.Vector3(2,0,0)) }));
pack.add(createMageFigure({ position: position.clone().add(new THREE.Vector3(4,0,0)) }));
scene.add(pack);
}
// βββ 3. HEROIC FANTASY CREATURES FULL PACK VOLΒ 1 βββββββββββββββββββββββββ
function createDemonicCreatureBase({ position=new THREE.Vector3() }) { /*β¦*/ }
function createFantasyAnimalBase({ position=new THREE.Vector3() }) { /*β¦*/ }
function createFantasyLizardBase({ position=new THREE.Vector3() }) { /*β¦*/ }
function createLivingDeadBase({ position=new THREE.Vector3() }) { /*β¦*/ }
function createFantasyVillainBase({ position=new THREE.Vector3() }) { /*β¦*/ }
function createMythologicalCreatureBase({ position=new THREE.Vector3() }) { /*β¦*/ }
function createHeroicFantasyCreaturesPack(position=new THREE.Vector3()) {
const grp = new THREE.Group();
grp.add(createDemonicCreatureBase({ position }));
grp.add(createFantasyAnimalBase({ position: position.clone().add(new THREE.Vector3(3,0,0)) }));
grp.add(createFantasyLizardBase({ position: position.clone().add(new THREE.Vector3(6,0,0)) }));
grp.add(createLivingDeadBase({ position: position.clone().add(new THREE.Vector3(9,0,0)) }));
grp.add(createFantasyVillainBase({ position: position.clone().add(new THREE.Vector3(12,0,0)) }));
grp.add(createMythologicalCreatureBase({ position: position.clone().add(new THREE.Vector3(15,0,0)) }));
scene.add(grp);
}
// βββ 4. POLYGON β Apocalypse Pack βββββββββββββββββββββββββββββββββββββββββ
function createZombieFigure({ position=new THREE.Vector3() }) { /*β¦*/ }
function createSurvivorFigure({ position=new THREE.Vector3() }) { /*β¦*/ }
function createBackpack({ position=new THREE.Vector3() }) { /*β¦*/ }
function createMakeshiftArmor({ position=new THREE.Vector3() }) { /*β¦*/ }
function createBuggyFrame({ position=new THREE.Vector3() }) { /*β¦*/ }
function createApocalypsePack(position=new THREE.Vector3()) {
const pack = new THREE.Group();
pack.add(createZombieFigure({ position }));
pack.add(createSurvivorFigure({ position: position.clone().add(new THREE.Vector3(3,0,0)) }));
pack.add(createBackpack({ position: position.clone().add(new THREE.Vector3(6,0,0)) }));
pack.add(createMakeshiftArmor({ position: position.clone().add(new THREE.Vector3(9,0,0)) }));
pack.add(createBuggyFrame({ position: position.clone().add(new THREE.Vector3(12,0,0)) }));
scene.add(pack);
}
// βββ Hook into your existing objectβplacement switch βββββββββββββββββββββ
window.placeObject = function(type, position) {
switch(type) {
case 'Cyberpunk City Builder Kit':
createCyberpunkKit(position);
break;
case 'POLYGON - Fantasy Kingdom Pack':
createFantasyKingdomPack(position);
break;
case 'HEROIC FANTASY CREATURES FULL PACKΒ VOLΒ 1':
createHeroicFantasyCreaturesPack(position);
break;
case 'POLYGON - Apocalypse Pack':
createApocalypsePack(position);
break;
// β¦ your existing cases for Simple House, Tree, etc. β¦
}
};
// βββ Initialize scene βββββββββββββββββββββββββββββββββββββββββββββββββββ
init();
</script>
</head>
<body>
<canvas id="canvas"></canvas>
<!-- your existing teleportPlayer, getSaveDataAndPosition hooks, etc. -->
</body>
</html>
|