mrchantey / koora Goto Github PK
View Code? Open in Web Editor NEWAssemblyscript 3D Game Framework
License: MIT License
Assemblyscript 3D Game Framework
License: MIT License
It'd be great to explore a method for laying out the data of components in a 'linear' manner, as seen in the sparse set ECS approach. I originally had ideas about using Typed Arrays for all primitives in components, because I have some understanding of how to get them to all share the same ArrayBuffer, but as @MaxGraey points out in PR #1 this is less than ideal due to the extra layer of abstraction.
I would love to learn how this can be achieved in AssemblyScript, I suppose the ideal solution would have the following:
Here's an example to hopefully clarify the problem that I'm having:
class MyComponent{
valA: f32
valB: Vector3
static byteStride: u16 = 32 // could this be auto generated?
}
const initialComponentCount = 10
//this is my imaginary alternative to ArrayBuffer
const componentPool = new MemoryAllocation(MyComponent.byteStride * initialComponentCount)
function addComponentToPool(index: u16){
//somehow the new instance is assigned to that location in memory
componentPool.set(new MyComponent(), MyComponent.byteStride * index)
}
function getComponentAtIndex(index:u16):MyComponent{
return componentPool.get(MyComponent.byteStride * index)
}
function doJavascriptWebGLThingWithComponent(index:u16){
// it may be better to do this cast in JS, so that we dont need to copy the data across on each usage
const poolAsBufferView = Uint8Array.from(componentPool)
const byteOffset = MyComponent.byteStride * index
gl.bufferData(gl.ArrayBuffer,poolAsBufferView,gl.STATIC_DRAW,byteOffset,MyComponent.stride)
}
Edit: Just discovered the following functions, perhaps some combination may do the trick:
export declare function load<T>(ptr: usize, immOffset?: usize, immAlign?: usize): T;
export declare function store<T>(ptr: usize, value: auto, immOffset?: usize, immAlign?: usize): void;
export declare function sizeof<T>(): usize; // | u32 / u64
export declare function alignof<T>(): usize; // | u32 / u64
export declare function offsetof<T>(fieldName?: string): usize; // | u32 / u64
export declare function changetype<T>(value: auto): T;
I found no other channel :D
Just wanted to say congratulations for your success with this project.
I've been working with AS in 2019 and doing some 3D / animation stuff.
I'd love to see this project evolving as I'm probably one of the developers who are in the perfect target group for a project like this. I'd love to create 3D scenes and small-scale games, but I'm absolutely not ready to jump into hardcore 3D game development with C++ and alike.
So thanks alot and I wish you success!!
Please don't let yourself get demotivated ... every start is hard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.