How to use the @casual-simulation/aux-common.calculateGridScale function in @casual-simulation/aux-common

To help you get started, we’ve selected a few @casual-simulation/aux-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / aux-server / aux-web / aux-player / scene / InventorySimulation3D.ts View on Github external
constructor(game: Game, simulation: BrowserSimulation) {
        super(game, simulation);

        // Generate a context group that will render the user's inventory for this simulation.
        this._contextGroup = new InventoryContextGroup3D(
            this,
            this.simulation.helper.userBot,
            'player',
            this.decoratorFactory
        );

        const calc = this.simulation.helper.createContext();
        let gridScale = calculateGridScale(calc, null);
        this.grid3D = new PlayerGrid3D(gridScale).showGrid(false);
        this.grid3D.useAuxCoordinates = true;
        this.add(this.grid3D);
    }
github casual-simulation / aux / src / aux-server / aux-web / aux-player / scene / PlayerSimulation3D.ts View on Github external
private _setupGrid(calc: BotCalculationContext) {
        if (this.grid3D) {
            this.remove(this.grid3D);
        }
        let gridScale = calculateGridScale(
            calc,
            this._contextGroup ? this._contextGroup.bot : null
        );
        this.grid3D = new PlayerGrid3D(gridScale).showGrid(false);
        this.grid3D.useAuxCoordinates = true;
    }
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / ScaleDecorator.ts View on Github external
fileUpdated(calc: FileCalculationContext): void {
        const gridScale = calculateGridScale(
            calc,
            this.file3D.contextGroup ? this.file3D.contextGroup.file : null
        );
        const scale = calculateScale(calc, this.file3D.file, gridScale);
        this.file3D.display.scale.set(scale.x, scale.y, scale.z);
    }
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / WorkspaceMesh.ts View on Github external
bots.forEach(bot => {
            if (isUserBot(bot.bot)) {
                return;
            }
            let localPosition = calculateGridTileLocalCenter(
                calculateBotValue(calc, bot.bot, bot.context + 'X'),
                calculateBotValue(calc, bot.bot, bot.context + 'Y'),
                calculateBotValue(calc, bot.bot, bot.context + 'Z'),
                calculateGridScale(calc, bot.contextGroup.bot)
            );

            let axial: Axial = realPosToGridPos(
                new Vector2(localPosition.x, localPosition.z),
                scale
            );
            const hexgrid = this.hexGrid.addAt(axial);
            hexgrid.height =
                centerHeight || defaultHeight || DEFAULT_WORKSPACE_HEIGHT;
        });
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / ContextPositionDecorator.ts View on Github external
botUpdated(calc: BotCalculationContext): void {
        const userContext = this.bot3D.context;
        if (userContext) {
            const scale = calculateGridScale(calc, this.bot3D.contextGroup.bot);
            const currentGridPos = getBotPosition(
                calc,
                this.bot3D.bot,
                this.bot3D.context
            );
            const currentHeight = calculateVerticalHeight(
                calc,
                this.bot3D.bot,
                this.bot3D.context,
                scale
            );
            this._nextPos = calculateObjectPositionInGrid(
                calc,
                this.bot3D,
                scale
            );