mirror of
https://github.com/xibyte/jsketcher
synced 2026-01-04 06:47:01 +01:00
add location support to the engine's API
This commit is contained in:
parent
871dcbf8fc
commit
5aa50327b2
5 changed files with 98 additions and 3 deletions
|
|
@ -406,7 +406,7 @@ export interface EngineAPI_V1 {
|
|||
transform(request: {
|
||||
|
||||
/**
|
||||
* Engine object reference ot transform
|
||||
* Engine object reference to transform
|
||||
*/
|
||||
model: Handle,
|
||||
|
||||
|
|
@ -417,6 +417,61 @@ export interface EngineAPI_V1 {
|
|||
|
||||
}): BrepOutputData;
|
||||
|
||||
/**
|
||||
* Sets the location for a model. Unlike the transform this method doesn't update the original geometry
|
||||
* but virtually moves/rotates the model.
|
||||
*/
|
||||
setLocation(request: {
|
||||
|
||||
/**
|
||||
* Engine object reference
|
||||
*/
|
||||
model: Handle,
|
||||
|
||||
/**
|
||||
* Location matrix represented as a flat array
|
||||
*/
|
||||
matrix: Matrix3x4FlatData;
|
||||
|
||||
}): void;
|
||||
|
||||
/**
|
||||
* Gets the location assign to the model
|
||||
* @see setLocation method
|
||||
*/
|
||||
getLocation(request: {
|
||||
|
||||
/**
|
||||
* Engine object reference
|
||||
*/
|
||||
model: Handle,
|
||||
|
||||
}): Matrix3x4FlatData;
|
||||
|
||||
/**
|
||||
* Returns the model's data
|
||||
*/
|
||||
getModelData(request: {
|
||||
|
||||
/**
|
||||
* Engine object reference
|
||||
*/
|
||||
model: Handle,
|
||||
|
||||
}): BrepOutputData;
|
||||
|
||||
/**
|
||||
* Deletes a given model from memory
|
||||
*/
|
||||
dispose(request: {
|
||||
|
||||
/**
|
||||
* Engine object reference
|
||||
*/
|
||||
model: Handle,
|
||||
|
||||
}): void;
|
||||
|
||||
}
|
||||
|
||||
export interface EngineSession {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ export const CubeExample: () => BrepInputData = () => ({
|
|||
faces: [
|
||||
{
|
||||
surface: 'top',
|
||||
loops: [['AB', 'BC', 'CD', 'DA']]
|
||||
loops: [
|
||||
['AB', 'BC', 'CD', 'DA']]
|
||||
},
|
||||
{
|
||||
surface: 'bottom',
|
||||
|
|
|
|||
|
|
@ -65,4 +65,19 @@ export class GenericWASMEngine_V1 implements EngineAPI_V1 {
|
|||
return callEngine(params, Module._SPI_transform);
|
||||
}
|
||||
|
||||
getLocation(params) {
|
||||
return callEngine(params, Module._SPI_getLocation);
|
||||
}
|
||||
|
||||
setLocation(params) {
|
||||
return callEngine(params, Module._SPI_setLocation);
|
||||
}
|
||||
|
||||
getModelData(params) {
|
||||
return callEngine(params, Module._SPI_getModelData);
|
||||
}
|
||||
|
||||
dispose(params) {
|
||||
return callEngine(params, Module._SPI_dispose);
|
||||
}
|
||||
}
|
||||
4
modules/engine/impl/wasm/externals.d.ts
vendored
4
modules/engine/impl/wasm/externals.d.ts
vendored
|
|
@ -15,4 +15,8 @@ declare var Module: {
|
|||
_SPI_loadModel: Function;
|
||||
_SPI_tessellate: Function;
|
||||
_SPI_transform: Function;
|
||||
_SPI_getLocation: Function;
|
||||
_SPI_setLocation: Function;
|
||||
_SPI_getModelData: Function;
|
||||
_SPI_dispose: Function;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -290,18 +290,38 @@ export function runSandbox(ctx: ApplicationContext) {
|
|||
|
||||
let data = ctx.craftEngine.modellingEngine.loadModel(box);
|
||||
|
||||
data = ctx.craftEngine.modellingEngine.transform({
|
||||
ctx.craftEngine.modellingEngine.setLocation({
|
||||
model: data.ptr,
|
||||
matrix: Matrix3x4.rotateMatrix(45 * DEG_RAD, AXIS.Y, ORIGIN).toFlatArray()
|
||||
});
|
||||
|
||||
data = ctx.craftEngine.modellingEngine.getModelData({
|
||||
model: data.ptr,
|
||||
});
|
||||
|
||||
const tessellation = ctx.craftEngine.modellingEngine.tessellate({
|
||||
model: data.ptr,
|
||||
deflection: 3
|
||||
});
|
||||
|
||||
const location = ctx.craftEngine.modellingEngine.getLocation({
|
||||
model: data.ptr
|
||||
});
|
||||
|
||||
console.log("Location: ->>> ");
|
||||
console.log(location);
|
||||
|
||||
console.log("Tesselation: ->>> ");
|
||||
console.log(tessellation);
|
||||
|
||||
// ctx.craftEngine.modellingEngine.dispose({
|
||||
// model: data.ptr
|
||||
// });
|
||||
//
|
||||
// ctx.craftEngine.modellingEngine.getLocation({
|
||||
// model: data.ptr
|
||||
// });
|
||||
|
||||
|
||||
const mBrepShell = readShellEntityFromJson(data);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue