844 ポリゴン0.94 × 2.18 × 0.70 m
コードで使う
エディターでリミックスwizard.js · 352 行
自己完結型の ES モジュールで、依存先は three のみです。ファクトリー関数を呼び出し、返された group をシーンに追加してください。
/**
* Wizard — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 844 · Size (W × H × D): 0.94 × 2.18 × 0.70 m
*
* Usage:
* import { createWizard } from './wizard.js';
*
* const model = createWizard();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
// Deterministic vertex displacement (organic low-poly look).
function jitter(geometry, amount, seed) {
const pos = geometry.attributes.position;
const h = (a, b, c, s) => {
let x = Math.imul(a, 73856093) ^ Math.imul(b, 19349663) ^ Math.imul(c, 83492791) ^ Math.imul(s, 2654435761);
x = Math.imul(x ^ (x >>> 16), 2246822507);
x = Math.imul(x ^ (x >>> 13), 3266489909);
return ((x ^ (x >>> 16)) >>> 0) / 4294967295 - 0.5;
};
for (let i = 0; i < pos.count; i++) {
const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);
const qx = Math.round(x * 1000), qy = Math.round(y * 1000), qz = Math.round(z * 1000);
pos.setXYZ(i, x + h(qx, qy, qz, seed) * 2 * amount, y + h(qx, qy, qz, seed + 1) * 2 * amount, z + h(qx, qy, qz, seed + 2) * 2 * amount);
}
pos.needsUpdate = true;
geometry.computeVertexNormals();
return geometry;
}
// 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 createWizard() {
const root = new THREE.Group();
root.name = 'Wizard';
// Materials
const robeMat = new THREE.MeshStandardMaterial({ name: 'robe', color: 0x5246b0, roughness: 0.85, flatShading: true });
const robeDarkMat = new THREE.MeshStandardMaterial({ name: 'robeDark', color: 0x352e72, roughness: 0.9, flatShading: true });
const trimMat = new THREE.MeshStandardMaterial({ name: 'trim', color: 0xf0c24c, roughness: 0.35, metalness: 0.55, flatShading: true });
const skinMat = new THREE.MeshStandardMaterial({ name: 'skin', color: 0xf1c3a0, roughness: 0.8, flatShading: true });
const beardMat = new THREE.MeshStandardMaterial({ name: 'beard', color: 0xeceae4, roughness: 0.95, flatShading: true });
const eyeMat = new THREE.MeshStandardMaterial({ name: 'eye', color: 0x1d1820, roughness: 0.35, flatShading: true });
const shineMat = new THREE.MeshStandardMaterial({ name: 'shine', color: 0xffffff, roughness: 0.3, flatShading: true });
const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0x7a5233, roughness: 0.85, flatShading: true });
const gemMat = new THREE.MeshStandardMaterial({ name: 'gem', color: 0x62e3ff, roughness: 0.15, emissive: 0x62e3ff, emissiveIntensity: 0.9, flatShading: true });
const bootMat = new THREE.MeshStandardMaterial({ name: 'boot', color: 0x4a3326, roughness: 0.8, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.15, 0.48, 0.16);
const boxGeo2 = new THREE.BoxGeometry(0.16, 0.1, 0.26);
const boxGeo3 = new THREE.BoxGeometry(0.1, 0.05, 0.08);
const extrudeGeo = extrude([[0, 0.03], [-0.0079, 0.0109], [-0.0285, 0.0093], [-0.0128, -0.0042], [-0.0176, -0.0243], [0, -0.0135], [0.0176, -0.0243], [0.0128, -0.0042], [0.0285, 0.0093], [0.0079, 0.0109]], 0.01);
const cylinderGeo = new THREE.CylinderGeometry(0.1061, 0.1556, 0.44, 4, 1, false, Math.PI / 4);
const cylinderGeo2 = new THREE.CylinderGeometry(0.1591, 0.1662, 0.05, 4, 1, false, Math.PI / 4);
const boxGeo4 = new THREE.BoxGeometry(0.11, 0.11, 0.11);
const cylinderGeo3 = new THREE.CylinderGeometry(0.018, 0.024, 0.156, 5);
const cylinderGeo4 = new THREE.CylinderGeometry(0.012, 0.018, 0.1687, 5);
const boxGeo5 = new THREE.BoxGeometry(0.05, 0.07, 0.01);
const boxGeo6 = new THREE.BoxGeometry(0.019, 0.019, 0.006);
const boxGeo7 = new THREE.BoxGeometry(0.14, 0.045, 0.04);
const boxGeo8 = new THREE.BoxGeometry(0.13, 0.05, 0.05);
// Parts
const legL = new THREE.Group();
legL.name = 'legL';
legL.position.set(0.11, 0.56, 0);
root.add(legL);
const shinL = new THREE.Mesh(boxGeo, robeDarkMat);
shinL.name = 'shinL';
shinL.position.set(0, -0.24, 0);
legL.add(shinL);
const bootL = new THREE.Mesh(boxGeo2, bootMat);
bootL.name = 'bootL';
bootL.position.set(0, -0.51, 0.1);
legL.add(bootL);
const bootToeL = new THREE.Mesh(boxGeo3, bootMat);
bootToeL.name = 'bootToeL';
bootToeL.position.set(0, -0.475, 0.245);
bootToeL.rotation.set(deg(-35), 0, 0);
legL.add(bootToeL);
const legR = new THREE.Group();
legR.name = 'legR';
legR.position.set(-0.11, 0.56, 0);
root.add(legR);
const shinR = new THREE.Mesh(boxGeo, robeDarkMat);
shinR.name = 'shinR';
shinR.position.set(0, -0.24, 0);
legR.add(shinR);
const bootR = new THREE.Mesh(boxGeo2, bootMat);
bootR.name = 'bootR';
bootR.position.set(0, -0.51, 0.1);
legR.add(bootR);
const bootToeR = new THREE.Mesh(boxGeo3, bootMat);
bootToeR.name = 'bootToeR';
bootToeR.position.set(0, -0.475, 0.245);
bootToeR.rotation.set(deg(-35), 0, 0);
legR.add(bootToeR);
const body = new THREE.Group();
body.name = 'body';
root.add(body);
const robe = new THREE.Mesh(new THREE.CylinderGeometry(0.3253, 0.495, 1.03, 4, 1, false, Math.PI / 4), robeMat);
robe.name = 'robe';
robe.position.set(0, 0.585, 0);
robe.scale.set(1, 1, 0.68);
body.add(robe);
const robeHem = new THREE.Mesh(new THREE.CylinderGeometry(0.4992, 0.5091, 0.06, 4, 1, false, Math.PI / 4), robeDarkMat);
robeHem.name = 'robeHem';
robeHem.position.set(0, 0.1, 0);
robeHem.scale.set(1, 1, 0.68);
body.add(robeHem);
const sash = new THREE.Mesh(new THREE.CylinderGeometry(0.4163, 0.4278, 0.07, 4, 1, false, Math.PI / 4), trimMat);
sash.name = 'sash';
sash.position.set(0, 0.62, 0);
sash.scale.set(1, 1, 0.68);
body.add(sash);
const sashKnot = new THREE.Mesh(new THREE.BoxGeometry(0.09, 0.09, 0.03), trimMat);
sashKnot.name = 'sashKnot';
sashKnot.position.set(0.1, 0.62, 0.2144);
body.add(sashKnot);
const sashTail = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.18, 0.02), trimMat);
sashTail.name = 'sashTail';
sashTail.position.set(0.12, 0.5, 0.2239);
sashTail.rotation.set(0, 0, deg(10));
body.add(sashTail);
const robeFrontTrim = new THREE.Mesh(new THREE.BoxGeometry(0.07, 0.51, 0.012), robeDarkMat);
robeFrontTrim.name = 'robeFrontTrim';
robeFrontTrim.position.set(0, 0.325, 0.2202);
robeFrontTrim.rotation.set(deg(4.5297), 0, 0);
body.add(robeFrontTrim);
const robeStar = new THREE.Mesh(extrude([[0, 0.04], [-0.0106, 0.0146], [-0.038, 0.0124], [-0.0171, -0.0056], [-0.0235, -0.0324], [0, -0.018], [0.0235, -0.0324], [0.0171, -0.0056], [0.038, 0.0124], [0.0106, 0.0146]], 0.01), trimMat);
robeStar.name = 'robeStar';
robeStar.position.set(-0.16, 0.36, 0.218);
robeStar.rotation.set(deg(4.5297), 0, 0);
body.add(robeStar);
const robeStar2 = new THREE.Mesh(extrudeGeo, trimMat);
robeStar2.name = 'robeStar';
robeStar2.position.set(0.17, 0.22, 0.2291);
robeStar2.rotation.set(deg(4.5297), 0, 0);
body.add(robeStar2);
const robeStar3 = new THREE.Mesh(extrude([[0, 0.025], [-0.0066, 0.0091], [-0.0238, 0.0077], [-0.0107, -0.0035], [-0.0147, -0.0202], [0, -0.0113], [0.0147, -0.0202], [0.0107, -0.0035], [0.0238, 0.0077], [0.0066, 0.0091]], 0.01), trimMat);
robeStar3.name = 'robeStar';
robeStar3.position.set(-0.07, 0.15, 0.2347);
robeStar3.rotation.set(deg(4.5297), 0, 0);
body.add(robeStar3);
const collar = new THREE.Mesh(new THREE.CylinderGeometry(0.2404, 0.2828, 0.07, 4, 1, false, Math.PI / 4), robeDarkMat);
collar.name = 'collar';
collar.position.set(0, 1.11, 0);
collar.scale.set(1, 1, 0.8);
body.add(collar);
const armL = new THREE.Group();
armL.name = 'armL';
armL.position.set(0.29, 1.03, 0);
armL.rotation.set(0, 0, deg(8));
root.add(armL);
const sleeveL = new THREE.Mesh(cylinderGeo, robeMat);
sleeveL.name = 'sleeveL';
sleeveL.position.set(0, -0.2, 0);
armL.add(sleeveL);
const cuffL = new THREE.Mesh(cylinderGeo2, trimMat);
cuffL.name = 'cuffL';
cuffL.position.set(0, -0.395, 0);
armL.add(cuffL);
const handL = new THREE.Mesh(boxGeo4, skinMat);
handL.name = 'handL';
handL.position.set(0, -0.47, 0);
armL.add(handL);
const armR = new THREE.Group();
armR.name = 'armR';
armR.position.set(-0.29, 1.03, 0);
armR.rotation.set(deg(-30), 0, deg(-10));
root.add(armR);
const sleeveR = new THREE.Mesh(cylinderGeo, robeMat);
sleeveR.name = 'sleeveR';
sleeveR.position.set(0, -0.2, 0);
armR.add(sleeveR);
const cuffR = new THREE.Mesh(cylinderGeo2, trimMat);
cuffR.name = 'cuffR';
cuffR.position.set(0, -0.395, 0);
armR.add(cuffR);
const handR = new THREE.Mesh(boxGeo4, skinMat);
handR.name = 'handR';
handR.position.set(0, -0.47, 0);
armR.add(handR);
const staff = new THREE.Group();
staff.name = 'staff';
staff.position.set(0, -0.47, 0);
staff.rotation.set(deg(29.6217), deg(4.9809), deg(8.6822));
armR.add(staff);
const staffShaft = new THREE.Mesh(new THREE.CylinderGeometry(0.026, 0.032, 1.788, 6), woodMat);
staffShaft.name = 'staffShaft';
staffShaft.position.set(0, 0.277, 0);
staff.add(staffShaft);
const staffKnot = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.055, 0), 0.008, 3), woodMat);
staffKnot.name = 'staffKnot';
staffKnot.position.set(0, 1.171, 0);
staff.add(staffKnot);
const staffProng = new THREE.Mesh(cylinderGeo3, woodMat);
staffProng.name = 'staffProng';
staffProng.position.set(0.04, 1.226, 0);
staffProng.rotation.set(0, 0, deg(-36.0274));
staff.add(staffProng);
const staffProngTip = new THREE.Mesh(cylinderGeo4, woodMat);
staffProngTip.name = 'staffProngTip';
staffProngTip.position.set(0.055, 1.351, 0);
staffProngTip.rotation.set(0, 0, deg(19.6538));
staff.add(staffProngTip);
const staffProng2 = new THREE.Mesh(cylinderGeo3, woodMat);
staffProng2.name = 'staffProng';
staffProng2.position.set(-0.04, 1.226, 0);
staffProng2.rotation.set(0, 0, deg(36.0274));
staff.add(staffProng2);
const staffProngTip2 = new THREE.Mesh(cylinderGeo4, woodMat);
staffProngTip2.name = 'staffProngTip';
staffProngTip2.position.set(-0.055, 1.351, 0);
staffProngTip2.rotation.set(0, 0, deg(-19.6538));
staff.add(staffProngTip2);
const staffCrystal = new THREE.Mesh(new THREE.OctahedronGeometry(0.065, 0), gemMat);
staffCrystal.name = 'staffCrystal';
staffCrystal.position.set(0, 1.321, 0);
staffCrystal.scale.set(1, 1.55, 1);
staff.add(staffCrystal);
const head = new THREE.Group();
head.name = 'head';
head.position.set(0, 1.08, 0);
root.add(head);
const skull = new THREE.Mesh(new THREE.BoxGeometry(0.46, 0.46, 0.46), skinMat);
skull.name = 'skull';
skull.position.set(0, 0.25, 0);
head.add(skull);
const eyeL = new THREE.Mesh(boxGeo5, eyeMat);
eyeL.name = 'eyeL';
eyeL.position.set(0.095, 0.27, 0.236);
head.add(eyeL);
const eyeShineL = new THREE.Mesh(boxGeo6, shineMat);
eyeShineL.name = 'eyeShineL';
eyeShineL.position.set(0.102, 0.2854, 0.242);
head.add(eyeShineL);
const browL = new THREE.Mesh(boxGeo7, beardMat);
browL.name = 'browL';
browL.position.set(0.095, 0.34, 0.242);
browL.rotation.set(0, 0, deg(-10));
head.add(browL);
const mustacheL = new THREE.Mesh(boxGeo8, beardMat);
mustacheL.name = 'mustacheL';
mustacheL.position.set(0.065, 0.155, 0.26);
mustacheL.rotation.set(0, 0, deg(14));
head.add(mustacheL);
const eyeR = new THREE.Mesh(boxGeo5, eyeMat);
eyeR.name = 'eyeR';
eyeR.position.set(-0.095, 0.27, 0.236);
head.add(eyeR);
const eyeShineR = new THREE.Mesh(boxGeo6, shineMat);
eyeShineR.name = 'eyeShineR';
eyeShineR.position.set(-0.102, 0.2854, 0.242);
head.add(eyeShineR);
const browR = new THREE.Mesh(boxGeo7, beardMat);
browR.name = 'browR';
browR.position.set(-0.095, 0.34, 0.242);
browR.rotation.set(0, 0, deg(10));
head.add(browR);
const mustacheR = new THREE.Mesh(boxGeo8, beardMat);
mustacheR.name = 'mustacheR';
mustacheR.position.set(-0.065, 0.155, 0.26);
mustacheR.rotation.set(0, 0, deg(-14));
head.add(mustacheR);
const nose = new THREE.Mesh(new THREE.BoxGeometry(0.085, 0.1, 0.08), skinMat);
nose.name = 'nose';
nose.position.set(0, 0.21, 0.265);
head.add(nose);
const beardJaw = new THREE.Mesh(new THREE.BoxGeometry(0.472, 0.17, 0.3), beardMat);
beardJaw.name = 'beardJaw';
beardJaw.position.set(0, 0.099, 0.086);
head.add(beardJaw);
const beard = new THREE.Mesh(extrude([[-0.235, 0], [0.235, 0], [0.22, -0.2], [0.13, -0.42], [0.02, -0.56], [-0.12, -0.44], [-0.21, -0.22]], 0.15), beardMat);
beard.name = 'beard';
beard.position.set(0, 0.18, 0.195);
head.add(beard);
const hairBack = new THREE.Mesh(new THREE.BoxGeometry(0.472, 0.28, 0.14), beardMat);
hairBack.name = 'hairBack';
hairBack.position.set(0, 0.28, -0.166);
head.add(hairBack);
const hat = new THREE.Group();
hat.name = 'hat';
hat.position.set(0, 0.435, -0.01);
hat.rotation.set(deg(-4), 0, 0);
head.add(hat);
const hatBrim = new THREE.Mesh(new THREE.CylinderGeometry(0.38, 0.38, 0.035, 8, 1, false, 0.3927), robeMat);
hatBrim.name = 'hatBrim';
hatBrim.position.set(0, 0.0175, 0);
hat.add(hatBrim);
const hatCrown = new THREE.Mesh(new THREE.CylinderGeometry(0.1909, 0.3111, 0.3, 4, 1, false, Math.PI / 4), robeMat);
hatCrown.name = 'hatCrown';
hatCrown.position.set(0, 0.18, 0);
hat.add(hatCrown);
const hatBand = new THREE.Mesh(new THREE.CylinderGeometry(0.2944, 0.3224, 0.07, 4, 1, false, Math.PI / 4), robeDarkMat);
hatBand.name = 'hatBand';
hatBand.position.set(0, 0.065, 0);
hat.add(hatBand);
const hatStar = new THREE.Mesh(extrude([[0, 0.055], [-0.0145, 0.02], [-0.0523, 0.017], [-0.0235, -0.0076], [-0.0323, -0.0445], [0, -0.0247], [0.0323, -0.0445], [0.0235, -0.0076], [0.0523, 0.017], [0.0145, 0.02]], 0.012), trimMat);
hatStar.name = 'hatStar';
hatStar.position.set(0, 0.2, 0.1748);
hatStar.rotation.set(deg(-15.8192), 0, 0);
hat.add(hatStar);
const hatTip = new THREE.Group();
hatTip.name = 'hatTip';
hatTip.position.set(0, 0.32, 0);
hatTip.rotation.set(deg(-16), 0, deg(6));
hat.add(hatTip);
const hatMiddle = new THREE.Mesh(new THREE.CylinderGeometry(0.1131, 0.1909, 0.22, 4, 1, false, Math.PI / 4), robeMat);
hatMiddle.name = 'hatMiddle';
hatMiddle.position.set(0, 0.1, 0);
hatTip.add(hatMiddle);
const hatPoint = new THREE.Group();
hatPoint.name = 'hatPoint';
hatPoint.position.set(0, 0.19, 0);
hatPoint.rotation.set(deg(-32), 0, deg(14));
hatTip.add(hatPoint);
const hatCone = new THREE.Mesh(new THREE.ConeGeometry(0.1131, 0.3, 4, 1, false, Math.PI / 4), robeMat);
hatCone.name = 'hatCone';
hatCone.position.set(0, 0.15, 0);
hatPoint.add(hatCone);
const hatStarSmall = new THREE.Mesh(extrudeGeo, trimMat);
hatStarSmall.name = 'hatStarSmall';
hatStarSmall.position.set(0.045, 0.08, 0.06);
hatStarSmall.rotation.set(deg(-18), deg(30), 0);
hatPoint.add(hatStarSmall);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createWizard;
評価とコメント
0 件のコメント
まだコメントはありません。このモデルの使い方や改善できる点を共有しましょう。
関連モデル
同じカテゴリまたは似たタグ









