-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Hi, sometimes when I refresh the page or freshly load in, the objects will sometimes not appear on screen, or the entire game does not load up the chunks and your left frozen, what's going on? the issue becomes more apparent when you add two meshes, where one mesh most of the time never appears on startup.
here's the code i've written
loadMesh.js
import * as BABYLON from "@babylonjs/core";
import "@babylonjs/loaders";
export async function makeMesh(noa, filedes, filename) {
const scene = noa.rendering.getScene()
const result = await BABYLON.SceneLoader.ImportMeshAsync(
"",
"../models/" + filedes + "/",
filename,
scene
)
const meshes = result.meshes.filter(m =>
m instanceof BABYLON.Mesh &&
m.getTotalVertices() > 0
)
const merged = BABYLON.Mesh.MergeMeshes(meshes, true, true)
meshes.forEach(m => m.dispose())
merged.rotationQuaternion = null
merged.isPickable = true
//merged.scaling.setAll(6);
merged.computeWorldMatrix(true);
merged.bakeCurrentTransformIntoVertices();
merged.metadata = {
eid: "prop",
raycastType: "entity"
}
return merged
}
entityfunctions.js
export function createEntity(noaInstance,x,y,z,mesh) {
var id = noaInstance.entities.add([x,y,z],1,1,mesh,[0,0,0],false,false);
return id;
}
main.js
/*
*
* noa hello-world example
*
* This is a bare-minimum example world, intended to be a
* starting point for hacking on noa game world content.
*
*/
// Engine options object, and engine instantiation.
import { Engine } from 'noa-engine'
import { loadImagePixels,loadCSVToMap,makeKey } from "./dataUtility";
import { createEntity, raycastEntitiesBabylon } from "./entityfunctions";
import { makeMesh } from "./loadMesh";
const csvVoxelMap = await loadCSVToMap('data.csv');
const levelData = await loadCSVToMap('leveldata.csv');
var playerData = new Map();
const imagePixels = await loadImagePixels("imgMap.png");
const imgWidth = imagePixels[0].length;
const imgHeight = imagePixels.length;
var noa = new Engine({
debug: true,
showFPS: true,
chunkSize: 48,
chunkAddDistance: [8.5, 6],
playerStart: [0, 10, 0],
playerAutoStep: true,
playerShadowComponent: false,
originRebaseDistance: 10,
})
var teleporterProp = await makeMesh(noa,'teleporter_inactive','teleporter_inactive.obj');
var teleporteractive = await makeMesh(noa,'teleporter_active','teleporter_active.obj');
var entity = createEntity(noa,328,87,637,teleporterProp);
var npc = createEntity(noa,300, 87, 637,teleporteractive);
var newPosition = [300, 87, 637];
// Move player instantly
noa.entities.setPosition(noa.playerEntity, newPosition)
//voxel generation to be made down below!
any two cents can help with this. It would be greatly appreciated
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels