Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private createCheckMarker() {
const prefab = this.preloads['check-marker'][0].prefab;
const actor = Actor.CreateFromPrefab(this.context, {
prefabId: prefab.id,
actor: {
name: 'check-marker',
parentId: this.boardOffset.id,
transform: { local: { position: { x: 1, y: 999, z: 1 } } }
}
});
this.checkMarker = actor;
return actor.created();
}
private createChessboard() {
const loads: Array> = [];
this.chessboard = Actor.CreateFromPrefab(this.context, {
prefabId: this.preloads['chessboard'][0].prefab.id,
actor: {
name: "chessboard",
parentId: this.sceneRoot.id,
}
});
loads.push(this.chessboard.created());
this.boardOffset = Actor.CreateEmpty(this.context, {
actor: {
name: "board-offset",
parentId: this.sceneRoot.id,
transform: {
local: {
position: { x: 0.135, z: 0.135 }
}
private createChessPieces() {
const loads: Array> = [];
const status = this.game.getStatus() as Status;
for (const square of status.board.squares) {
if (square.piece) {
const side = modelConfigs[square.piece.side.name];
const info = side[square.piece.type];
const name = `${square.piece.side.name}-${square.piece.type}`;
const position = new Vector3();
position.copy(this.coordinate(square));
const prefab = this.preloads[`${square.piece.side.name}-${square.piece.type}`][0].prefab;
const actor = Actor.CreateFromPrefab(this.context, {
prefabId: prefab.id,
actor: {
name,
parentId: this.boardOffset.id,
transform: { local: { position, rotation: info.rotation } },
subscriptions: ['transform']
}
});
square.piece.actor = actor;
loads.push(actor.created());
}
}
return loads;
}
private createMoveMarkers() {
const loads: Array> = [];
const status = this.game.getStatus() as Status;
for (const square of status.board.squares) {
const position = new Vector3();
position.copy(this.coordinate(square));
position.y = 1000;
const prefab = this.preloads['move-marker'][0].prefab;
const actor = Actor.CreateFromPrefab(this.context, {
prefabId: prefab.id,
actor: {
name: 'move-marker',
parentId: this.boardOffset.id,
transform: { local: { position } }
}
});
square.marker = actor;
loads.push(actor.created());
}
return loads;
}