fix erorrs
This commit is contained in:
@@ -69,21 +69,21 @@ function prepare_animations(model) {
|
||||
duration = input_acc.max[0]
|
||||
}
|
||||
|
||||
channels.push({
|
||||
channels[] = {
|
||||
node: chan.target.node,
|
||||
path: chan.target.path,
|
||||
interpolation: sampler.interpolation,
|
||||
times: times_blob,
|
||||
values: values_blob,
|
||||
count: input_acc.count
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
prepared.push({
|
||||
prepared[] = {
|
||||
name: anim.name,
|
||||
duration: duration,
|
||||
channels: channels
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return prepared
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[dependencies]
|
||||
mload = "/Users/john/work/cell-model"
|
||||
sdl3 = "/Users/john/work/cell-sdl3"
|
||||
cell-image = "/Users/john/work/cell-image"
|
||||
mload = "/Users/johnalanbrook/work/cell-model"
|
||||
sdl3 = "/Users/johnalanbrook/work/cell-sdl3"
|
||||
cell-image = "/Users/johnalanbrook/work/cell-image"
|
||||
|
||||
@@ -20,7 +20,7 @@ function add_sphere(transform, radius, opts) {
|
||||
layer_mask: _opts.layer_mask || 1,
|
||||
user: _opts.user
|
||||
}
|
||||
_colliders.push(c)
|
||||
_colliders[] = c
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ function add_box(transform, size, opts) {
|
||||
layer_mask: _opts.layer_mask || 1,
|
||||
user: _opts.user
|
||||
}
|
||||
_colliders.push(c)
|
||||
_colliders[] = c
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ function overlaps(layer_mask_a, layer_mask_b) {
|
||||
if (layer_mask_b != null && !(b.layer_mask & layer_mask_b)) continue
|
||||
|
||||
if (_check_collision(a, b)) {
|
||||
results.push({a: a, b: b})
|
||||
results[] = {a: a, b: b}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
73
core.cm
73
core.cm
@@ -185,7 +185,7 @@ function log_msg() {
|
||||
var args = []
|
||||
var i = null
|
||||
for (i = 0; i < length(arguments); i++) {
|
||||
args.push(text(arguments[i]))
|
||||
args[] = text(arguments[i])
|
||||
}
|
||||
log.console("[lance3d] " + text(args, " "))
|
||||
}
|
||||
@@ -300,17 +300,26 @@ function make_sphere(r, segments) {
|
||||
ny = math.cosine(theta)
|
||||
nz = math.sine(theta) * math.sine(phi)
|
||||
|
||||
positions.push(nx * r, ny * r, nz * r)
|
||||
normals.push(nx, ny, nz)
|
||||
uvs.push(u, v)
|
||||
positions[] = nx * r
|
||||
positions[] = ny * r
|
||||
positions[] = nz * r
|
||||
normals[] = nx
|
||||
normals[] = ny
|
||||
normals[] = nz
|
||||
uvs[] = u
|
||||
uvs[] = v
|
||||
}
|
||||
}
|
||||
|
||||
for (y = 0; y < _segments; y++) {
|
||||
for (x = 0; x < _segments; x++) {
|
||||
i = y * (_segments + 1) + x
|
||||
indices.push(i, i + 1, i + _segments + 1)
|
||||
indices.push(i + 1, i + _segments + 2, i + _segments + 1)
|
||||
indices[] = i
|
||||
indices[] = i + 1
|
||||
indices[] = i + _segments + 1
|
||||
indices[] = i + 1
|
||||
indices[] = i + _segments + 2
|
||||
indices[] = i + _segments + 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,19 +346,33 @@ function make_cylinder(r, h, segments) {
|
||||
nx = math.cosine(angle)
|
||||
nz = math.sine(angle)
|
||||
|
||||
positions.push(nx * r, -hh, nz * r)
|
||||
normals.push(nx, 0, nz)
|
||||
uvs.push(u, 1)
|
||||
positions[] = nx * r
|
||||
positions[] = -hh
|
||||
positions[] = nz * r
|
||||
normals[] = nx
|
||||
normals[] = 0
|
||||
normals[] = nz
|
||||
uvs[] = u
|
||||
uvs[] = 1
|
||||
|
||||
positions.push(nx * r, hh, nz * r)
|
||||
normals.push(nx, 0, nz)
|
||||
uvs.push(u, 0)
|
||||
positions[] = nx * r
|
||||
positions[] = hh
|
||||
positions[] = nz * r
|
||||
normals[] = nx
|
||||
normals[] = 0
|
||||
normals[] = nz
|
||||
uvs[] = u
|
||||
uvs[] = 0
|
||||
}
|
||||
|
||||
for (i = 0; i < _segments; i++) {
|
||||
base = i * 2
|
||||
indices.push(base, base + 1, base + 2)
|
||||
indices.push(base + 1, base + 3, base + 2)
|
||||
indices[] = base
|
||||
indices[] = base + 1
|
||||
indices[] = base + 2
|
||||
indices[] = base + 1
|
||||
indices[] = base + 3
|
||||
indices[] = base + 2
|
||||
}
|
||||
|
||||
return _make_mesh_from_arrays(positions, normals, uvs, indices)
|
||||
@@ -383,11 +406,11 @@ function anim_info(model) {
|
||||
var anim = null
|
||||
for (i = 0; i < length(internal.animations); i++) {
|
||||
anim = internal.animations[i]
|
||||
result.push({
|
||||
result[] = {
|
||||
name: anim.name || ("clip_" + text(i)),
|
||||
duration: anim.duration || 0,
|
||||
index: i
|
||||
})
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -449,7 +472,7 @@ function sample_pose(model, name, time_val) {
|
||||
}
|
||||
|
||||
for (ni = 0; ni < length(internal.nodes); ni++) {
|
||||
pose.node_matrices.push(resources_mod.get_transform_world_matrix(internal.nodes[ni]))
|
||||
pose.node_matrices[] = resources_mod.get_transform_world_matrix(internal.nodes[ni])
|
||||
}
|
||||
|
||||
// Build skin palettes if model has skins
|
||||
@@ -462,13 +485,13 @@ function sample_pose(model, name, time_val) {
|
||||
node_idx = skin.joints[j]
|
||||
jnode = internal.nodes[node_idx]
|
||||
if (jnode) {
|
||||
world_matrices.push(resources_mod.get_transform_world_matrix(jnode))
|
||||
world_matrices[] = resources_mod.get_transform_world_matrix(jnode)
|
||||
} else {
|
||||
world_matrices.push(model_c.mat4_identity())
|
||||
world_matrices[] = model_c.mat4_identity()
|
||||
}
|
||||
}
|
||||
palette = model_c.build_joint_palette(world_matrices, skin.inv_bind, skin.joint_count)
|
||||
pose.skin_palettes.push(palette)
|
||||
pose.skin_palettes[] = palette
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,13 +541,13 @@ function draw_model(model, transform, pose) {
|
||||
if (extra_transform) {
|
||||
jworld = model_c.mat4_mul(extra_transform, jworld)
|
||||
}
|
||||
world_matrices.push(jworld)
|
||||
world_matrices[] = jworld
|
||||
} else {
|
||||
world_matrices.push(model_c.mat4_identity())
|
||||
world_matrices[] = model_c.mat4_identity()
|
||||
}
|
||||
}
|
||||
palette = model_c.build_joint_palette(world_matrices, skin.inv_bind, skin.joint_count)
|
||||
skin_palettes.push(palette)
|
||||
skin_palettes[] = palette
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,14 +721,14 @@ function _check_tri_budget() {
|
||||
// ============================================================================
|
||||
|
||||
function _queue_draw(mesh, uniforms, texture, opts) {
|
||||
_state._pending_draws.push({
|
||||
_state._pending_draws[] = {
|
||||
mesh: mesh,
|
||||
uniforms: uniforms,
|
||||
texture: texture,
|
||||
coverage: opts.coverage || "opaque",
|
||||
face: opts.face || "single",
|
||||
palette: opts.palette
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function _build_uniforms(model_mat, view_mat, proj_mat, mat) {
|
||||
|
||||
@@ -112,7 +112,7 @@ function _draw() {
|
||||
var cam_y = math.sine(cam_pitch) * cam_distance + 0.5
|
||||
var cam_z = math.cosine(cam_yaw) * math.cosine(cam_pitch) * cam_distance
|
||||
|
||||
lance3d.camera_look_at(cam_x, cam_y, cam_z, 0, 0.5, 0)
|
||||
lance3d.camera_look_at({x: cam_x, y: cam_y, z: cam_z}, {x: 0, y: 0.5, z: 0})
|
||||
|
||||
// Draw the cube with transform
|
||||
var cube_transform = lance3d.translation_matrix(0, 0.5, 0)
|
||||
|
||||
@@ -78,14 +78,14 @@ function _init() {
|
||||
x = (lance3d.rand() - 0.5) * 90
|
||||
z = (lance3d.rand() - 0.5) * 90
|
||||
|
||||
trees.push({
|
||||
trees[] = {
|
||||
x: x,
|
||||
z: z,
|
||||
trunk_h: lance3d.rand() * 3 + 2,
|
||||
trunk_r: lance3d.rand() * 0.25 + 0.25,
|
||||
canopy_s: lance3d.rand() * 1.0 + 1.5,
|
||||
canopy_mat: lance3d.rand() < 0.5 ? canopy_mat_a : canopy_mat_b
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
last_time = time_mod.number()
|
||||
|
||||
24
resources.cm
24
resources.cm
@@ -157,20 +157,20 @@ function load_model(path, style, tier) {
|
||||
img = g.images[ti]
|
||||
tex = null
|
||||
if (img && img.pixels) {
|
||||
original_images.push({
|
||||
original_images[] = {
|
||||
width: img.pixels.width,
|
||||
height: img.pixels.height,
|
||||
pixels: img.pixels.pixels
|
||||
})
|
||||
}
|
||||
if (style) {
|
||||
tex = create_texture_for_platform(img.pixels, style, tier)
|
||||
} else {
|
||||
tex = _backend.create_texture(img.pixels.width, img.pixels.height, img.pixels.pixels)
|
||||
}
|
||||
} else {
|
||||
original_images.push(null)
|
||||
original_images[] = null
|
||||
}
|
||||
textures.push(tex)
|
||||
textures[] = tex
|
||||
}
|
||||
|
||||
// Create materials
|
||||
@@ -196,13 +196,13 @@ function load_model(path, style, tier) {
|
||||
if (gmat.alpha_mode == "MASK") coverage = "cutoff"
|
||||
else if (gmat.alpha_mode == "BLEND") coverage = "blend"
|
||||
|
||||
materials.push({
|
||||
materials[] = {
|
||||
color_map: color_map,
|
||||
paint: paint,
|
||||
coverage: coverage,
|
||||
face: gmat.double_sided ? "double" : "single",
|
||||
lamp: gmat.unlit ? "unlit" : "lit"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Build internal model structure for animations/skins
|
||||
@@ -226,7 +226,7 @@ function load_model(path, style, tier) {
|
||||
t.mesh_index = node.mesh
|
||||
t.name = node.name
|
||||
t.gltf_children = node.children || []
|
||||
internal_model.nodes.push(t)
|
||||
internal_model.nodes[] = t
|
||||
}
|
||||
|
||||
// Set up parent-child relationships
|
||||
@@ -243,7 +243,7 @@ function load_model(path, style, tier) {
|
||||
// Find root nodes
|
||||
for (ni = 0; ni < length(internal_model.nodes); ni++) {
|
||||
if (!internal_model.nodes[ni].parent) {
|
||||
internal_model.root_nodes.push(internal_model.nodes[ni])
|
||||
internal_model.root_nodes[] = internal_model.nodes[ni]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ function load_model(path, style, tier) {
|
||||
gpu_mesh.name = mesh.name
|
||||
gpu_mesh.mesh_index = mi
|
||||
gpu_mesh.primitive_index = pi
|
||||
internal_model.meshes.push(gpu_mesh)
|
||||
internal_model.meshes[] = gpu_mesh
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,11 +278,11 @@ function load_model(path, style, tier) {
|
||||
mat_idx = mesh.material_index
|
||||
mat = (mat_idx != null && materials[mat_idx]) ? materials[mat_idx] : meme(_default_material)
|
||||
|
||||
result.push({
|
||||
result[] = {
|
||||
mesh: mesh,
|
||||
material: mat,
|
||||
_node_index: ni
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ function _transform_set_parent(child, parent) {
|
||||
if (idx != null) child.parent.children.splice(idx, 1)
|
||||
}
|
||||
child.parent = parent
|
||||
if (parent) parent.children.push(child)
|
||||
if (parent) parent.children[] = child
|
||||
child.dirty_world = true
|
||||
}
|
||||
|
||||
|
||||
5
sdl.cm
5
sdl.cm
@@ -164,8 +164,8 @@ function get_pipeline(skinned, alpha_mode, cull) {
|
||||
{ location: 3, buffer_slot: 0, format: "float4", offset: 32 }
|
||||
]
|
||||
if (skinned) {
|
||||
vertex_attrs.push({ location: 4, buffer_slot: 0, format: "float4", offset: 48 })
|
||||
vertex_attrs.push({ location: 5, buffer_slot: 0, format: "float4", offset: 64 })
|
||||
vertex_attrs[] = { location: 4, buffer_slot: 0, format: "float4", offset: 48 }
|
||||
vertex_attrs[] = { location: 5, buffer_slot: 0, format: "float4", offset: 64 }
|
||||
}
|
||||
|
||||
var pipeline =gpu_mod.graphics_pipeline(_gpu, {
|
||||
@@ -333,6 +333,7 @@ function submit_frame(draws, clear_color, clear_depth, style_id) {
|
||||
var swap_pass = cmd.render_pass(pass_desc)
|
||||
|
||||
// Sort draws: opaque first, then cutoff, then blend
|
||||
var order = { opaque: 0, cutoff: 1, blend: 2 }
|
||||
var keys = array(draws, d => {
|
||||
var k = order[d.coverage]
|
||||
return k == null ? 0 : k
|
||||
|
||||
8
skin.cm
8
skin.cm
@@ -39,14 +39,14 @@ function prepare_skins(model) {
|
||||
}
|
||||
}
|
||||
|
||||
prepared.push({
|
||||
prepared[] = {
|
||||
name: skin.name,
|
||||
joints: skin.joints,
|
||||
joint_count: length(skin.joints),
|
||||
inv_bind: inv_bind_blob,
|
||||
skeleton: skin.skeleton,
|
||||
palette: null // Will be built each frame
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return prepared
|
||||
@@ -68,9 +68,9 @@ function build_palette(skin, model, retro3d) {
|
||||
node = model.nodes[node_idx]
|
||||
if (node) {
|
||||
world_mat = retro3d.transform_get_world_matrix(node)
|
||||
world_matrices.push(world_mat)
|
||||
world_matrices[] = world_mat
|
||||
} else {
|
||||
world_matrices.push(model_c.mat4_identity())
|
||||
world_matrices[] = model_c.mat4_identity()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user