graphics3d/toon/meshbuilder
툰 3D 모형 짓기. (vanilla.js graphics3d/toon/meshbuilder.js 의 MeshBuilder 와 기본 도형)
- 툰 3D(점토 같은 한 색 재질과 바깥선)를 그릴 꼭짓점 배열을 짓는다. 외계행성 광부 키우기의 판 3D 에서 왔다. (three.js 의 기본 도형과 같은 꼴)
- 도형은 가운데가 원점인 자기 좌표로 짓는다. 부품을 더할 때 자리, 돌림, 크기를 곱해 한 덩어리에 담는다.
- 꼭짓점 하나는 자리 3, 노멀 3, 색 3(sRGB), 재질 2(빛남의 세기, 빛을 받지 않음), 무늬 4(무늬 번호, 무늬 색) 이다. 무늬 번호와 색의 뜻은 그리는 셰이더가 정한다. (0 이면 무늬 없음)
- 텍스처 좌표(UV)는 꼭짓점 배열 밖의 uv_data 에 꼭짓점마다 2 씩 따로 담는다. UV 를 준 꼭짓점이 하나라도 있으면 나머지는 0 으로 채운다. (도형의 uvs, add_triangles_with_uvs)
- 2 번 UV 도 같은 꼴로 uv1_data 에 담는다. (도형의 uvs1, add_triangles_with_uvs 의 uvs1, GLB 의 TEXCOORD_1, 천사 고리처럼 두 번째 펼침을 읽는 것) (0, 0) 이 그림의 왼쪽 위다. (glTF 와 같음) 상자는 면마다 0 ~ 1, 구는 경도와 위도로 0 ~ 1 이다.
- 재질 범위(material_ranges)는 몸의 꼭짓점 번호 가운데 한 재질이 든 자리다. GLB 읽기가 프리미티브마다 담는다. (재질 이름, extras, 텍스처, ToonDrawOptions 의 index_start, index_count)
- 바깥선은 부품의 점마다 같은 굵기로 민 껍데기다. 뒷면만 그리므로 따로 담는다. (inverted hull)
- 삼각형의 감기는 꼭짓점 노멀을 보고 바깥이 앞면이 되게 맞춘다. (뒷면 가리기와 바깥선이 감기에 기댄다)
Building toon 3D models. (MeshBuilder and basic shapes of vanilla.js graphics3d/toon/meshbuilder.js)
- Builds the vertex array used to draw toon 3D (single-color clay-like material with outlines). It came from the in-board 3D of webgame-rimminer. (Same form as the three.js basic geometries)
- Shapes are built in their own coordinates with the center at the origin. When a part is added, position, rotation and scale are multiplied in and it is put into one lump.
- One vertex is position 3, normal 3, color 3 (sRGB), material 2 (glow strength, unlit), pattern 4 (pattern number, pattern color). The meaning of the pattern number and color is decided by the shader that draws it. (0 means no pattern)
- Texture coordinates (UV) are stored separately, 2 per vertex, in uv_data outside the vertex array. If even one vertex was given a UV, the rest are filled with 0. (uvs of a shape, add_triangles_with_uvs)
- The second UV is stored the same way in uv1_data. (uvs1 of a shape, uvs1 of add_triangles_with_uvs, TEXCOORD_1 of GLB, for things that read a second unwrap such as the angel ring) (0, 0) is the top left of the image. (Same as glTF) A box is 0 ~ 1 per face, a sphere is 0 ~ 1 by longitude and latitude.
- A material range (material_ranges) is the span of body vertex indices that holds one material. The GLB reader stores one per primitive. (Material name, extras, textures, index_start and index_count of ToonDrawOptions)
- The outline is a shell pushed out by the same thickness at every point of the part. Since only its back faces are drawn, it is stored separately. (inverted hull)
- Triangle winding is fixed by looking at the vertex normals so the outside becomes the front face. (Back-face culling and the outline rely on winding)
ToonGeometrystruct traits Clone, Debug, Default
기본 도형. (가운데가 원점인 자리, 노멀, 꼭짓점 번호)
- uvs 는 점마다 텍스처 좌표 둘이다. (상자와 구만 짓는다, 비면 없음)
Basic shape. (positions centered at the origin, normals, vertex indices)
- uvs are two texture coordinates per point. (only boxes and spheres build them, none if empty)
use vanilla::create_box_geometry;
let geometry = create_box_geometry(1.0, 2.0, 3.0);
assert_eq!(geometry.positions.len(), 24 * 3);
assert_eq!(geometry.normals.len(), geometry.positions.len());
assert_eq!(geometry.indices.len(), 36);
assert_eq!(geometry.uvs.len(), 24 * 2);
assert!(geometry.uvs1.is_empty());점마다 텍스처 좌표 둘. (상자와 구만 짓는다, 비면 없음)
Two texture coordinates per point. (Only boxes and spheres build them, empty means none)
반환ReturnsVec<f64>
점마다 2 번 텍스처 좌표 둘. (비면 없음)
Two second UV texture coordinates per point. (none if empty)
반환ReturnsVec<f64>
ToonPartOptionsstruct traits Clone, Copy, Debug, Default
부품을 더할 때의 꼴. (빛남, 빛을 받지 않음, 바깥선 여부와 굵기)
Options for adding a part. (emissive, unlit, whether it has an outline and its width)
use std::f64::consts::PI;
use vanilla::{create_cylinder_geometry, create_sphere_geometry, Matrix4, MeshBuilder, ToonPartOptions};
let mut builder = MeshBuilder::new();
builder.add_part(&create_sphere_geometry(0.5, 24, 16, PI), &Matrix4::create_translation(0.0, 0.5, 0.0), "#f0e0d0", ToonPartOptions { outline_width: 0.03, ..ToonPartOptions::default() });
builder.add_part(&create_sphere_geometry(0.06, 10, 8, PI), &Matrix4::create_translation(0.15, 0.6, 0.45), "#40ffff", ToonPartOptions { glow: 2.0, is_unlit: true, has_outline: false, ..ToonPartOptions::default() });
let outline_index_count = builder.get_outline_index_count();
builder.add_part(&create_cylinder_geometry(0.5, 0.5, 0.01, 24), &Matrix4::create_translation(0.0, 0.005, 0.0), "#202020", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
assert_eq!(builder.get_outline_index_count(), outline_index_count);빛남의 세기. (꼭짓점의 재질 첫 칸, 0 이면 빛나지 않음)
Emissive strength. (first material slot of the vertex, 0 for no emission)
반환Returnsf64
빛을 받지 않음. (꼭짓점의 재질 둘째 칸, 그늘 없이 제 색)
Unlit. (second material slot of the vertex, its own color without shading)
반환Returnsbool
바깥선 굵기. (기본 DEFAULT_OUTLINE_WIDTH)
Outline width. (default DEFAULT_OUTLINE_WIDTH)
반환Returnsf64
ToonQuadstruct traits Clone, Copy, Debug
네모 면 하나. (네 점은 둘레 차례, 면의 바깥쪽 노멀)
One quad. (four points in perimeter order, outward face normal)
use vanilla::{MeshBuilder, ToonQuad};
let mut builder = MeshBuilder::new();
let quads = [
ToonQuad { corners: [[0.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, 1.0, 1.0], [0.0, 1.0, 1.0]], normal: [0.0, 1.0, 0.0] },
ToonQuad { corners: [[0.0, 0.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0], [0.0, 1.0, 1.0]], normal: [0.0, 0.0, 1.0] },
];
for quad in quads.iter() {
builder.add_quad(quad.corners, quad.normal, [0.5, 0.4, 0.3], 0.0, None, false);
}
builder.add_quad_shell(&quads, 0.02);
assert_eq!(builder.get_index_count(), 12);
assert_eq!(builder.get_outline_index_count(), 12);네 점. ([x, y, z], 둘레 차례)
Four points. ([x, y, z], in order around)
반환Returns[[f64; 3]; 4]
면의 바깥쪽 노멀. ([x, y, z])
Outward normal of the face. ([x, y, z])
반환Returns[f64; 3]
ToonMeshArraysstruct traits Clone, Debug, Default
다 지은 배열. (몸, 바깥선 껍데기, 뼈대 번호와 무게, 뼈대)
The built arrays. (body, outline shell, joint indices and weights, skeleton)
use vanilla::{create_box_geometry, Matrix4, MeshBuilder, ToonPartOptions, VERTEX_FLOAT_COUNT};
let mut builder = MeshBuilder::new();
builder.add_part(&create_box_geometry(1.0, 1.0, 1.0), &Matrix4::create_identity(), "#ff8844", ToonPartOptions::default());
let arrays = builder.read_arrays();
assert_eq!(arrays.vertex_data.len() / VERTEX_FLOAT_COUNT, 24);
assert_eq!(arrays.index_data.len(), 36);
assert_eq!(arrays.outline_vertex_data.len(), arrays.outline_base_data.len());
assert_eq!(arrays.uv_data.len(), 24 * 2);
assert!(arrays.skeleton.is_none());몸의 꼭짓점. (VERTEX_FLOAT_COUNT 씩)
Body vertices. (VERTEX_FLOAT_COUNT each)
반환ReturnsVec<f32>
몸의 삼각형마다 꼭짓점 번호 셋.
Three vertex indices per body triangle.
반환ReturnsVec<u32>
바깥선 껍데기의 자리. (3 씩)
Outline shell positions. (3 each)
반환ReturnsVec<f32>
바깥선 껍데기의 삼각형마다 점 번호 셋.
Three point indices per outline shell triangle.
반환ReturnsVec<u32>
바깥선 껍데기의 점마다 밀기 전 몸의 자리. (3 씩, 받은 껍데기는 그 자리 그대로)
Body position before pushing, per outline shell point. (3 each, a received shell keeps its position as is)
반환ReturnsVec<f32>
꼭짓점마다 뼈대 번호 넷과 무게 넷. (뼈대가 있는 모형만, SKIN_FLOAT_COUNT 씩)
Four joint indices and four weights per vertex. (skinned models only, SKIN_FLOAT_COUNT each)
반환ReturnsVec<f32>
바깥선 껍데기의 점마다 뼈대 번호 넷과 무게 넷.
Four joint indices and four weights per outline shell point.
반환ReturnsVec<f32>
뼈대. (read_glb_arrays 가 채운다, MeshBuilder 는 None)
Skeleton. (filled by read_glb_arrays, None for MeshBuilder)
반환ReturnsOption<ToonSkeleton>
GLB 의 안쪽 껍데기와 안쪽 몸이 든 자리. ((시작, 개수) 들, read_glb_arrays 가 채운다)
Spans of the GLB's inner shell and inner body. ((start, count) pairs, filled by read_glb_arrays)
반환ReturnsVec<(usize, usize)>
안쪽 몸이 든 자리. ((시작, 개수) 들, 몸의 꼭짓점 번호, read_glb_arrays 가 채운다)
Span holding the inner body. ((start, count) pairs, body vertex indices, filled by read_glb_arrays)
반환ReturnsVec<(usize, usize)>
꼭짓점마다 텍스처 좌표 둘. (UV 를 준 꼭짓점이 없으면 빈 것)
Two texture coordinates per vertex. (empty if no vertex was given UVs)
반환ReturnsVec<f32>
꼭짓점마다 2 번 텍스처 좌표 둘. (2 번 UV 를 준 꼭짓점이 없으면 빈 것)
Two second UV texture coordinates per vertex. (Empty if no vertex was given a second UV)
반환ReturnsVec<f32>
재질 범위. (GLB 프리미티브마다)
Material ranges. (per GLB primitive)
반환ReturnsVec<ToonMaterialRange>
ToonMaterialRangestruct traits Clone, Debug, Default
재질 범위. (몸의 꼭짓점 번호 가운데 한 재질이 든 자리, GLB 읽기가 프리미티브마다 담는다)
- name 재질 이름, material_index 재질 차례(없으면 None), node_name 노드 이름, extras 재질 extras, alpha_mode "OPAQUE" | "MASK" | "BLEND", alpha_cutoff (MASK 의 문턱)
- base_color_factor, emissive_factor 는 선형 색이다. base_color_image, emissive_image 는 read_glb_images 의 차례다. (없으면 None)
- 부품 안에서 칸을 갈라 칠할 때(강조색 칸, 표시판) 재질 이름이나 extras 로 고르고 ToonDrawOptions 의 index_start, index_count 로 그 칸만 그린다.
Material range. (span of body vertex indices holding one material, the GLB reader stores one per primitive)
- name material name, material_index material index (None if absent), node_name node name, extras material extras, alpha_mode "OPAQUE" | "MASK" | "BLEND", alpha_cutoff (the MASK threshold)
- base_color_factor and emissive_factor are linear colors. base_color_image and emissive_image are indices into read_glb_images. (None if absent)
- To paint separate regions within a part (accent color regions, display panels), pick them by material name or extras and draw only that region with index_start and index_count of ToonDrawOptions.
use vanilla::{create_box_geometry, Matrix4, MeshBuilder, ToonMaterialRange, ToonPartOptions};
let mut builder = MeshBuilder::new();
builder.add_part(&create_box_geometry(1.0, 1.0, 1.0), &Matrix4::create_identity(), "#909090", ToonPartOptions::default());
let screen_start = builder.get_index_count();
builder.add_part(&create_box_geometry(0.6, 0.4, 0.02), &Matrix4::create_translation(0.0, 0.1, 0.51), "#102030", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
let screen_count = builder.get_index_count() - screen_start;
builder.add_material_range(ToonMaterialRange { name: String::from("screen"), index_start: screen_start, index_count: screen_count, ..ToonMaterialRange::default() });
let arrays = builder.read_arrays();
let screen_range = arrays.material_ranges.iter().find(|material_range| material_range.name == "screen").unwrap();
assert_eq!((screen_range.index_start, screen_range.index_count), (36, 36));재질 차례. (프리미티브에 재질이 없으면 None)
Material order. (None if the primitive has no material)
반환ReturnsOption<usize>
프리미티브가 든 노드 이름. (없으면 빈 글자)
Name of the node that holds the primitive. (Empty text if none)
반환ReturnsString
몸의 꼭짓점 번호 가운데 이 재질이 시작하는 자리. (ToonDrawOptions 의 index_start)
Where this material starts among the body vertex indices. (index_start of ToonDrawOptions)
반환Returnsusize
이 재질이 든 꼭짓점 번호 수. (ToonDrawOptions 의 index_count)
Number of vertex indices holding this material. (index_count of ToonDrawOptions)
반환Returnsusize
재질 extras. (없으면 빈 객체)
Material extras. (Empty object if none)
반환ReturnsValue
glTF 의 alphaMode. ("OPAQUE", "MASK", "BLEND", GLB 에 없으면 "OPAQUE")
glTF alphaMode. ("OPAQUE", "MASK", "BLEND", "OPAQUE" if absent in the GLB)
반환ReturnsString
MASK 의 문턱. (GLB 에 없으면 0.5)
Threshold of MASK. (0.5 if absent in the GLB)
반환Returnsf64
바탕색 배. (선형 [r, g, b, a], GLB 에 없으면 1)
Base color factor. (Linear [r, g, b, a], 1 if absent in the GLB)
반환Returns[f64; 4]
빛남 색. (선형 [r, g, b], GLB 에 없으면 0)
Emissive color. (Linear [r, g, b], 0 if absent in the GLB)
반환Returns[f64; 3]
바탕색 텍스처의 그림 차례. (read_glb_images 의 차례, 없으면 None)
Image order of the base color texture. (Order in read_glb_images, None if none)
반환ReturnsOption<usize>
빛남 텍스처의 그림 차례. (read_glb_images 의 차례, 없으면 None)
Image order of the emissive texture. (Order in read_glb_images, None if none)
반환ReturnsOption<usize>
이 프리미티브에 텍스처 좌표가 있는지.
Whether this primitive has texture coordinates.
반환Returnsbool
ToonMeshPiecestruct traits Clone, Copy, Debug
잇는 조각 하나. (MeshBuilder::combine 에 넘기는 배열과 옮김, 원본 { arrays, offset })
One piece to join. (arrays and offset passed to MeshBuilder::combine, the original { arrays, offset })
use vanilla::{create_faceted_chunk_geometry, Matrix4, MeshBuilder, ToonMeshPiece, ToonPartOptions};
let mut builder = MeshBuilder::new();
builder.add_part(&create_faceted_chunk_geometry(0.4, &[1.0, 0.8, 1.1, 0.9], [1.0, 0.7, 1.0]), &Matrix4::create_identity(), "#8a8070", ToonPartOptions::default());
let rock_arrays = builder.read_arrays();
let pieces = [
ToonMeshPiece { arrays: &rock_arrays, offset: [0.0, 0.0, 0.0] },
ToonMeshPiece { arrays: &rock_arrays, offset: [1.2, 0.0, 0.3] },
ToonMeshPiece { arrays: &rock_arrays, offset: [-0.8, 0.0, 1.0] },
];
let combined_arrays = MeshBuilder::combine(&pieces);
assert_eq!(combined_arrays.index_data.len(), rock_arrays.index_data.len() * 3);
assert_eq!(combined_arrays.outline_index_data.len(), rock_arrays.outline_index_data.len() * 3);이을 배열. (read_arrays 나 read_glb_arrays 의 결과)
Arrays to join. (Result of read_arrays or read_glb_arrays)
반환Returns&'a ToonMeshArrays
자리에 더할 옮김. ([x, y, z])
Offset to add to positions. ([x, y, z])
반환Returns[f64; 3]
MeshBuilderstruct traits Default
모형 한 덩어리를 짓는 것.
Builder for one model chunk.
use std::f64::consts::PI;
use vanilla::{create_box_geometry, create_cylinder_geometry, create_part_matrix, Matrix4, MeshBuilder, ToonPartOptions};
let mut builder = MeshBuilder::new();
builder.add_part(&create_box_geometry(1.2, 0.4, 0.6), &Matrix4::create_translation(0.0, 0.4, 0.0), "#c04040", ToonPartOptions::default());
let wheel_start = builder.get_index_count();
builder.add_part(&create_cylinder_geometry(0.2, 0.2, 0.1, 16), &create_part_matrix(None, [0.4, 0.2, 0.35], Some([PI / 2.0, 0.0, 0.0]), None), "#303030", ToonPartOptions::default());
let wheel_count = builder.get_index_count() - wheel_start;
assert_eq!(wheel_start, 36);
assert!(wheel_count > 0);use std::f64::consts::PI;
use vanilla::{create_rounded_box_geometry, create_sphere_geometry, Camera3D, Matrix4, MeshBuilder, ToonDrawOptions, ToonPartOptions, ToonRenderer, Vector3};
fn draw_lamp(gl: &vanilla::GlContext, renderer: &mut ToonRenderer, camera: &mut Camera3D) {
let mut builder = MeshBuilder::new();
builder.add_part(&create_rounded_box_geometry(1.0, 0.5, 0.6, 3, 0.1), &Matrix4::create_translation(0.0, 0.25, 0.0), "#d0d8e0", ToonPartOptions::default());
let lamp_start = builder.get_index_count();
builder.add_part(&create_sphere_geometry(0.12, 12, 8, PI), &Matrix4::create_translation(0.5, 0.35, 0.0), "#ffe080", ToonPartOptions { glow: 1.5, is_unlit: true, ..ToonPartOptions::default() });
let lamp_count = builder.get_index_count() - lamp_start;
let Some(mesh) = renderer.create_mesh(gl, &builder.read_arrays()) else {
return;
};
camera.set_perspective(0.8, 0.1, 100.0);
camera.look_at(Vector3::create(1.5, 1.2, 2.0), Vector3::create(0.0, 0.2, 0.0), Vector3::create(0.0, 1.0, 0.0));
renderer.begin_frame_with_camera(gl, camera);
renderer.draw_mesh(gl, &mesh, &Matrix4::create_identity(), ToonDrawOptions { index_start: 0, index_count: lamp_start, ..ToonDrawOptions::default() });
renderer.draw_mesh(gl, &mesh, &Matrix4::create_identity(), ToonDrawOptions { index_start: lamp_start, index_count: lamp_count, tint_color: [1.0, 0.5, 0.5, 1.0], has_outline: false, ..ToonDrawOptions::default() });
renderer.end_frame(gl);
}생성.
Constructor.
반환ReturnsMeshBuilder 빈 MeshBuilder.An empty MeshBuilder.
짝Counterpart: vanilla.js MeshBuilder.constructor
pub fn read_outline_offsets(world_positions: &[f64], world_normals: &[f64], outline_width: f64) -> Vec<f64>#바깥선 껍데기의 점마다 밀어낼 만큼. (같은 자리의 점끼리 함께 민다)
- 같은 자리의 점(날카로운 모서리, 이음매, 극)은 서로 다른 법선을 한 번씩 더한 쪽으로 함께 밀어 껍데기가 벌어지지 않게 한다.
- 모서리에서는 맞닿은 면마다 굵기만큼 떨어지게 더 민다. (그 쪽과 면 법선의 가장 작은 코사인으로 나눈다, 0.85 밑으로 내리지 않는다)
Push amount per point of the outline shell. (points at the same position are pushed together)
- Points at the same position (sharp edges, seams, poles) are pushed together toward the sum of their distinct normals, each added once, so the shell does not split open.
- At edges, pushes further so it stays the width away from each adjoining face. (divided by the smallest cosine between that direction and the face normals, not lowered below 0.85)
- world_positions&[f64]
- 행렬을 곱한 꼭짓점 자리. (3 씩)Vertex positions with the matrix applied. (3 each)
- world_normals&[f64]
- 단위 법선.Unit normal.
- outline_widthf64
- 껍데기 굵기.Shell thickness.
반환ReturnsVec<f64> 점마다 밀어낼 [x, y, z]. (3 씩)[x, y, z] to push out per point. (3 each)
짝Counterpart: vanilla.js MeshBuilder.readOutlineOffsets
지어 둔 배열 여럿을 옮겨 한 배열로 잇기. (움직이지 않는 조각을 한 메시로, 돌리거나 키우지 않음, 원본 MeshBuilder.combine)
- 조각마다 배열과 옮김. 자리에 옮김을 더하고 번호에 앞 조각의 꼭짓점 수를 더한다. 바깥선 껍데기와 껍데기 기준 자리, 안쪽 범위도 같이 옮겨 잇는다.
- 뼈대는 잇지 않는다. 뼈대가 있는 조각도 쉬는 자세 그대로 움직이지 않는 몸이 된다.
Translates several built arrays and joins them into one array. (static pieces into one mesh, no rotation or scaling, the original MeshBuilder.combine)
- Arrays and offset per piece. Adds the offset to positions and the previous pieces' vertex count to indices. The outline shell, the shell reference positions and the inner ranges are also translated and joined.
- Skeletons are not joined. Even a piece with a skeleton becomes a static body in its rest pose.
- piece_list&[ToonMeshPiece]
- 이을 조각들. (배열과 옮김)Pieces to join. (Arrays and offset)
반환ReturnsToonMeshArrays read_arrays 의 꼴. (skeleton 은 None)The form of read_arrays. (skeleton is None)
짝Counterpart: vanilla.js MeshBuilder.combine
비었는지.
Whether it is empty.
반환Returnsbool 몸의 삼각형이 하나도 없으면 true.true if the body has no triangles.
짝Counterpart: vanilla.js MeshBuilder.isEmpty
지금까지 담은 몸의 꼭짓점 번호 수. (한 부위의 몸이 든 자리를 따로 그릴 때 그 앞뒤로 읽는다)
Number of body vertex indices stored so far. (read before and after a part when drawing that part's body span separately)
반환Returnsusize 몸의 꼭짓점 번호 수. (index_data 의 길이)Number of body vertex indices. (Length of index_data)
짝Counterpart: vanilla.js MeshBuilder.getIndexCount
지금까지 담은 바깥선 껍데기의 꼭짓점 번호 수.
Number of outline shell vertex indices stored so far.
반환Returnsusize 바깥선 껍데기의 꼭짓점 번호 수. (outline_index_data 의 길이)Number of outline shell vertex indices. (Length of outline_index_data)
짝Counterpart: vanilla.js MeshBuilder.getOutlineIndexCount
pub fn add_part(&mut self, geometry: &ToonGeometry, matrix: &Matrix4, color_text: &str, options: ToonPartOptions)#부품 하나 더하기. (도형에 행렬을 곱해 담고, 바깥선이면 점마다 민 껍데기도 담는다)
Adds one part. (stores the shape multiplied by the matrix, and with an outline also stores a shell pushed out per point)
- geometry&ToonGeometry
- 도형. (uvs 와 uvs1 은 비어도 된다)Shape. (uvs and uvs1 may be empty)
- matrix&Matrix4
- 도형에 곱할 자리, 돌림, 크기 행렬.Position, rotation and scale matrix to multiply into the shape.
- color_text&str
- "#rrggbb"
- optionsToonPartOptions
- 빛남, 빛을 받지 않음, 바깥선 여부와 굵기. (ToonPartOptions::default() 면 바깥선 있음)Glow, unlit, whether to have an outline and its thickness. (ToonPartOptions::default() has an outline)
짝Counterpart: vanilla.js MeshBuilder.addPart
pub fn add_quad(&mut self, corners: [[f64; 3]; 4], normal: [f64; 3], color: [f64; 3], pattern: f64, pattern_color: Option<[f64; 3]>, is_unlit: bool)#네모 면 하나 더하기. (블록 지형과 바닥 같은 면, 네 점은 둘레 차례, 바깥선 없음)
Adds one quad. (faces like block terrain and floors, four points in perimeter order, no outline)
- corners[[f64; 3]; 4]
- 네 점 [x, y, z]Four points [x, y, z]
- normal[f64; 3]
- [x, y, z]
- color[f64; 3]
- [r, g, b] sRGB.
- patternf64
- 무늬 번호. (뜻은 셰이더가 정함, 0 이면 없음)Pattern number. (meaning decided by the shader, 0 means none)
- pattern_colorOption<[f64; 3]>
- [r, g, b] 무늬 색. (없으면 None)[r, g, b] pattern color. (None if none)
- is_unlitbool
- 빛을 받지 않음.Unlit.
짝Counterpart: vanilla.js MeshBuilder.addQuad
네모 면들의 바깥선 껍데기 담기. (면으로 지은 지형 덩어리처럼)
- 같은 자리의 꼭짓점마다 서로 다른 면 법선을 한 번씩 더해 정규화하고, 그쪽으로 굵기만큼 민다.
Stores the outline shell of quads. (like terrain chunks built from faces)
- For each vertex at the same position, the distinct face normals are added once each and normalized, and it is pushed that way by the width.
- quads&[ToonQuad]
- 네모 면들. (네 점과 바깥쪽 노멀)Quad faces. (Four points and an outward normal)
- outline_widthf64
- 껍데기 굵기. (꼭짓점 좌표 길이)Shell thickness. (Length in vertex coordinates)
짝Counterpart: vanilla.js MeshBuilder.addQuadShell
pub fn add_triangles(&mut self, positions: &[f64], normals: &[f64], indices: &[u32], matrix: &Matrix4, color: [f64; 3], glow: f64, is_unlit: bool, joints: Option<&[f64]>, weights: Option<&[f64]>)#받은 모형의 삼각형 담기. (GLB 의 프리미티브 하나, 감기는 그대로)
Stores triangles of a loaded model. (one GLB primitive, winding kept as is)
- positions&[f64]
- 꼭짓점마다 [x, y, z].[x, y, z] per vertex.
- normals&[f64]
- 꼭짓점마다 [x, y, z] 노멀.[x, y, z] normal per vertex.
- indices&[u32]
- 삼각형마다 꼭짓점 번호 셋.Three vertex indices per triangle.
- matrix&Matrix4
- 꼭짓점에 곱할 행렬.Matrix to multiply into the vertices.
- color[f64; 3]
- [r, g, b] sRGB.
- glowf64
- 빛남의 세기. (바탕색에 곱해 더함, 0 이면 없음)Glow strength. (Multiplied by the base color and added, 0 means none)
- is_unlitbool
- 빛을 받지 않음.Unlit.
- jointsOption<&[f64]>
- 꼭짓점마다 뼈대 번호 넷. (없으면 None)Four joint indices per vertex. (None if none)
- weightsOption<&[f64]>
- 꼭짓점마다 무게 넷.Four weights per vertex.
짝Counterpart: vanilla.js MeshBuilder.addTriangles
pub fn add_triangles_with_uvs(&mut self, positions: &[f64], normals: &[f64], indices: &[u32], matrix: &Matrix4, color: [f64; 3], glow: f64, is_unlit: bool, joints: Option<&[f64]>, weights: Option<&[f64]>, uvs: Option<&[f64]>, uvs1: Option<&[f64]>)#받은 모형의 삼각형을 텍스처 좌표와 함께 담기. (uvs, uvs1 은 꼭짓점마다 둘, 원본 addTriangles 의 마지막 두 선택 인자)
Stores the triangles of a loaded model along with texture coordinates. (uvs, uvs1 are two per vertex, the last two optional arguments of the original addTriangles)
- positions&[f64]
- 꼭짓점마다 [x, y, z].[x, y, z] per vertex.
- normals&[f64]
- 꼭짓점마다 [x, y, z] 노멀.[x, y, z] normal per vertex.
- indices&[u32]
- 삼각형마다 꼭짓점 번호 셋.Three vertex indices per triangle.
- matrix&Matrix4
- 꼭짓점에 곱할 행렬.Matrix to multiply into the vertices.
- color[f64; 3]
- [r, g, b] sRGB.
- glowf64
- 빛남의 세기. (바탕색에 곱해 더함, 0 이면 없음)Glow strength. (Multiplied by the base color and added, 0 means none)
- is_unlitbool
- 빛을 받지 않음.Unlit.
- jointsOption<&[f64]>
- 꼭짓점마다 뼈대 번호 넷. (없으면 None)Four joint indices per vertex. (None if none)
- weightsOption<&[f64]>
- 꼭짓점마다 무게 넷.Four weights per vertex.
- uvsOption<&[f64]>
- 꼭짓점마다 텍스처 좌표 둘. (없으면 None)Two texture coordinates per vertex. (None if none)
- uvs1Option<&[f64]>
- 꼭짓점마다 2 번 텍스처 좌표 둘. (없으면 None)Two second texture coordinates per vertex. (None if none)
재질 범위 담기. (몸의 꼭짓점 번호 자리, GLB 읽기가 프리미티브마다 담는다)
Stores a material range. (span of body vertex indices, the GLB reader stores one per primitive)
- material_rangeToonMaterialRange
- 몸의 꼭짓점 번호 자리. (read_arrays 의 material_ranges 에 복사해 담긴다)Span of body vertex indices. (Copied into material_ranges of read_arrays)
짝Counterpart: vanilla.js MeshBuilder.addMaterialRange
pub fn add_outline_triangles(&mut self, positions: &[f64], indices: &[u32], matrix: &Matrix4, joints: Option<&[f64]>, weights: Option<&[f64]>)#받은 모형의 바깥선 껍데기 담기. (이미 부풀린 것, 감기는 그대로)
Stores the outline shell of a loaded model. (already inflated, winding kept as is)
- positions&[f64]
- 이미 부풀린 껍데기의 꼭짓점마다 [x, y, z].[x, y, z] per vertex of an already inflated shell.
- indices&[u32]
- 삼각형마다 꼭짓점 번호 셋. (감기는 그대로 담는다)Three vertex indices per triangle. (Winding is stored as is)
- matrix&Matrix4
- 꼭짓점에 곱할 행렬.Matrix to multiply into the vertices.
- jointsOption<&[f64]>
- 꼭짓점마다 뼈대 번호 넷. (없으면 None)Four joint indices per vertex. (None if none)
- weightsOption<&[f64]>
- 꼭짓점마다 무게 넷. (없으면 None)Four weights per vertex. (None if none)
짝Counterpart: vanilla.js MeshBuilder.addOutlineTriangles
pub fn add_triangle_shell(&mut self, positions: &[f64], normals: &[f64], indices: &[u32], matrix: &Matrix4, outline_width: f64, joints: Option<&[f64]>, weights: Option<&[f64]>)#받은 모형의 몸으로 바깥선 껍데기 짓기. (add_part 의 바깥선과 같은 셈, 감기는 그대로, 뼈대 번호와 무게는 몸의 것 그대로)
- 여러 프리미티브를 이어 붙여 한 번에 넘기면 프리미티브 사이의 같은 자리 점도 함께 민다.
Builds an outline shell from a loaded model's body. (same computation as add_part's outline, winding kept as is, joint indices and weights taken from the body as is)
- If several primitives are concatenated and passed at once, points at the same position across primitives are pushed together too.
- positions&[f64]
- 몸의 꼭짓점마다 [x, y, z].[x, y, z] per body vertex.
- normals&[f64]
- 몸의 꼭짓점마다 [x, y, z] 노멀.[x, y, z] normal per body vertex.
- indices&[u32]
- 삼각형마다 꼭짓점 번호 셋.Three vertex indices per triangle.
- matrix&Matrix4
- 꼭짓점에 곱할 행렬.Matrix to multiply into the vertices.
- outline_widthf64
- 껍데기 굵기. (행렬을 곱한 뒤의 길이)Shell thickness. (Length after the matrix is applied)
- jointsOption<&[f64]>
- 꼭짓점마다 뼈대 번호 넷. (없으면 None)Four joint indices per vertex. (None if none)
- weightsOption<&[f64]>
- 꼭짓점마다 무게 넷. (없으면 None)Four weights per vertex. (None if none)
짝Counterpart: vanilla.js MeshBuilder.addTriangleShell
다 지은 배열.
The built arrays.
반환ReturnsToonMeshArrays 지금까지 담은 것을 복사한 배열. (skeleton 은 None, UV 는 준 꼭짓점이 있을 때만 꼭짓점마다 둘)Arrays copied from everything stored so far. (skeleton is None, UV is two per vertex only when some vertex was given one)
짝Counterpart: vanilla.js MeshBuilder.readArrays
함수Functions
색 글자를 sRGB 세 수로. ("#rrggbb" → [r, g, b], 0 ~ 1)
Color string to three sRGB numbers. ("#rrggbb" → [r, g, b], 0 ~ 1)
- color_text&str
- "#rrggbb" 색 글자."#rrggbb" color text.
반환Returns[f64; 3] [r, g, b] sRGB. (0 ~ 1, 읽지 못하면 흰색)[r, g, b] sRGB. (0 ~ 1, white if it cannot be read)
짝Counterpart: vanilla.js readColorValues
pub fn create_part_matrix(parent_matrix: Option<&Matrix4>, position: [f64; 3], rotation: Option<[f64; 3]>, scale: Option<[f64; 3]>) -> Matrix4#자리, 돌림, 크기로 변환 행렬 짓기. (부모 행렬 뒤에 곱함, 돌림은 three.js 의 기본 차례 XYZ)
Builds a transform matrix from position, rotation and scale. (multiplied after the parent matrix, rotation uses three.js default order XYZ)
- parent_matrixOption<&Matrix4>
- 부모 행렬. (None 이면 단위 행렬)Parent matrix. (None means identity)
- position[f64; 3]
- [x, y, z]
- rotationOption<[f64; 3]>
- [x, y, z] 라디안. (None 이면 돌리지 않음)[x, y, z] radians. (None means no rotation)
- scaleOption<[f64; 3]>
- [x, y, z] (None 이면 키우지 않음)[x, y, z] (None means no scaling)
반환ReturnsMatrix4 부모 x 자리 x 돌림 x 크기 행렬. (새 행렬)Parent x translation x rotation x scale matrix. (New matrix)
짝Counterpart: vanilla.js createPartMatrix
네모 상자. (면마다 꼭짓점을 따로 두어 모서리가 날카롭다)
Box. (separate vertices per face so edges are sharp)
- widthf64
- X 축 길이.X axis length.
- heightf64
- Y 축 길이.Y axis length.
- depthf64
- Z 축 길이.Z axis length.
반환ReturnsToonGeometry { positions, normals, indices, uvs } 도형. (면마다 UV 0 ~ 1){ positions, normals, indices, uvs } shape. (UV 0 ~ 1 per face)
짝Counterpart: vanilla.js createBoxGeometry
pub fn create_rounded_box_geometry(width: f64, height: f64, depth: f64, segments: u32, radius: f64) -> ToonGeometry#모서리가 둥근 상자. (면마다 격자를 깔고 안쪽 상자에서 반지름만큼 밀어낸다)
Rounded box. (lays a grid on each face and pushes out from an inner box by the radius)
- widthf64
- X 축 길이.X axis length.
- heightf64
- Y 축 길이.Y axis length.
- depthf64
- Z 축 길이.Z axis length.
- segmentsu32
- 둥근 곳의 마디 수. (1 보다 작으면 1)Number of segments in the rounded parts. (1 if less than 1)
- radiusf64
- 모서리 반지름. (반 길이보다 크면 그 축은 다 둥글다)Corner radius. (If larger than the half length, that axis is fully rounded)
반환ReturnsToonGeometry { positions, normals, indices } 도형.{ positions, normals, indices } shape.
짝Counterpart: vanilla.js createRoundedBoxGeometry
pub fn create_cylinder_geometry(radius_top: f64, radius_bottom: f64, height: f64, radial_segments: u32) -> ToonGeometry#원기둥. (위와 아래 반지름이 다르면 깔때기, 위가 0 이면 원뿔, 위아래 뚜껑 포함)
Cylinder. (a funnel if the top and bottom radii differ, a cone if the top is 0, includes top and bottom caps)
- radius_topf64
- 위 반지름. (0 이면 원뿔)Top radius. (0 makes a cone)
- radius_bottomf64
- 아래 반지름.Bottom radius.
- heightf64
- 높이. (가운데가 원점)Height. (Center at the origin)
- radial_segmentsu32
- 둘레 마디 수.Number of segments around.
반환ReturnsToonGeometry { positions, normals, indices } 도형.{ positions, normals, indices } shape.
짝Counterpart: vanilla.js createCylinderGeometry
pub fn create_sphere_geometry(radius: f64, width_segments: u32, height_segments: u32, theta_length: f64) -> ToonGeometry#구. (위에서부터 theta_length 까지, π/2 면 위쪽 반구)
Sphere. (from the top down to theta_length, π/2 gives the upper hemisphere)
- radiusf64
- 반지름.Radius.
- width_segmentsu32
- 경도 마디 수.Number of longitude segments.
- height_segmentsu32
- 위도 마디 수.Number of latitude segments.
- theta_lengthf64
- 위에서부터 깎을 각. (라디안, π 면 온 구)Angle to cut from the top. (Radians, π makes a full sphere)
반환ReturnsToonGeometry { positions, normals, indices, uvs } 도형. (UV 는 경도와 위도로 0 ~ 1){ positions, normals, indices, uvs } shape. (UV 0 ~ 1 by longitude and latitude)
짝Counterpart: vanilla.js createSphereGeometry
돌려 깎기. (옆모습의 점 [x, y] 들을 Y 축으로 돌림, 노멀은 옆모습의 기울기로)
Lathe. (revolves the profile points [x, y] around the Y axis, normals from the profile slope)
- points&[[f64; 2]]
- 옆모습의 점 [x, y] 들. (아래에서 위로)Profile points [x, y]. (From bottom to top)
- segmentsu32
- 둘레 마디 수.Number of segments around.
반환ReturnsToonGeometry { positions, normals, indices } 도형.{ positions, normals, indices } shape.
짝Counterpart: vanilla.js createLatheGeometry
pub fn create_capsule_geometry(radius: f64, length: f64, cap_segments: u32, radial_segments: u32) -> ToonGeometry#캡슐. (가운데 길이 length 의 원기둥 위아래에 반구, 전체 높이는 length + 반지름 둘)
Capsule. (hemispheres on the top and bottom of a middle cylinder of length length, total height is length + two radii)
- radiusf64
- 반지름.Radius.
- lengthf64
- 가운데 원기둥의 길이. (반구는 빼고)Length of the middle cylinder. (Without the hemispheres)
- cap_segmentsu32
- 반구 하나의 위도 마디 수.Number of latitude segments of one hemisphere.
- radial_segmentsu32
- 둘레 마디 수.Number of segments around.
반환ReturnsToonGeometry { positions, normals, indices } 도형.{ positions, normals, indices } shape.
짝Counterpart: vanilla.js createCapsuleGeometry
pub fn create_torus_geometry(radius: f64, tube: f64, radial_segments: u32, tubular_segments: u32, arc: f64) -> ToonGeometry#고리. (XY 평면에 누운 고리, arc 만큼만)
Torus. (a ring lying on the XY plane, only as far as arc)
- radiusf64
- 고리의 반지름.Radius of the ring.
- tubef64
- 관의 반지름.Radius of the tube.
- radial_segmentsu32
- 관을 도는 마디.Segments around the tube.
- tubular_segmentsu32
- 고리를 도는 마디.Segments around the ring.
- arcf64
- 고리를 도는 각. (라디안, 2π 면 온 고리)Angle to go around the ring. (Radians, 2π makes a full ring)
반환ReturnsToonGeometry { positions, normals, indices } 도형.{ positions, normals, indices } shape.
짝Counterpart: vanilla.js createTorusGeometry
팔면체. (면마다 꼭짓점을 따로 두어 각진 결정)
Octahedron. (separate vertices per face for an angular crystal)
- radiusf64
- 가운데에서 꼭짓점까지.From the center to a vertex.
반환ReturnsToonGeometry { positions, normals, indices } 도형.{ positions, normals, indices } shape.
짝Counterpart: vanilla.js createOctahedronGeometry
pub fn create_faceted_chunk_geometry(radius: f64, vertex_scales: &[f64], axis_scale: [f64; 3]) -> ToonGeometry#각진 돌덩이. (이십면체의 꼭짓점 열둘을 저마다 늘이고 줄여, 면마다 꼭짓점을 따로 둔 깎은 돌, 원본 createFacetedChunkGeometry)
- vertex_scales 는 꼭짓점 열둘의 반지름 배다. 모자라면 처음부터 되풀이하고, 비면 1 이다. axis_scale 은 [x, y, z] 배.
Faceted rock. (each of the twelve icosahedron vertices is stretched or shrunk, a cut stone with separate vertices per face, the original createFacetedChunkGeometry)
- vertex_scales are radius multipliers for the twelve vertices. If short, they repeat from the start, and 1 if empty. axis_scale is the [x, y, z] multiplier.
- radiusf64
- 기준 반지름.Base radius.
- vertex_scales&[f64]
- 꼭짓점 열둘의 반지름 배. (모자라면 처음부터 되풀이, 비면 1)Radius multipliers of the twelve vertices. (Repeats from the start if short, 1 if empty)
- axis_scale[f64; 3]
- [x, y, z] 배.[x, y, z] multiplier.
반환ReturnsToonGeometry { positions, normals, indices }
짝Counterpart: vanilla.js createFacetedChunkGeometry
노멀에 곱할 3x3. (행렬 왼쪽 위 3x3 의 역의 전치, 행 차례)
3x3 to multiply normals by. (transpose of the inverse of the matrix's upper-left 3x3, row order)
- elements&[f64; 16]
- Matrix4 의 수.Elements of a Matrix4.
반환Returns[f64; 9] 노멀에 곱할 3x3 의 수 9. (행 차례, 행렬식이 0 에 가까우면 단위 행렬)Nine numbers of the 3x3 to multiply into normals. (Row order, identity if the determinant is near 0)
상수Constants
꼭짓점 하나의 수 개수. (자리 3, 노멀 3, 색 3, 재질 2, 무늬 4)
Number of values per vertex. (position 3, normal 3, color 3, material 2, pattern 4)
반환Returnsusize
짝Counterpart: vanilla.js VERTEX_FLOAT_COUNT
뼈대가 있는 모형의 꼭짓점마다 따로 담는 수 개수. (뼈대 번호 4, 무게 4)
Number of values stored separately per vertex for models with a skeleton. (joint indices 4, weights 4)
반환Returnsusize
짝Counterpart: vanilla.js SKIN_FLOAT_COUNT
바깥선의 기본 굵기.
Default outline width.
반환Returnsf64