Skip to content

Commit

Permalink
Merge branch 'main' into fix-fpc-initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd authored Jan 17, 2025
2 parents c520aed + 112b859 commit fb14177
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
32 changes: 10 additions & 22 deletions scripts/esm/grid.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ import {

/** @import { AppBase, Entity } from 'playcanvas' */

/**
* @typedef {object} ScriptArgs
* @property {AppBase} app - The app.
* @property {Entity} entity - The entity.
* @property {boolean} [enabled] - The enabled state.
* @property {object} [attributes] - The attributes.
*/

const tmpVa = new Vec2();

const EPISILON = 1e-3;
Expand Down Expand Up @@ -183,16 +175,7 @@ class Grid extends Script {
*/
_resolution = Grid.RESOLUTION_HIGH;

/**
* @param {ScriptArgs} args - The arguments.
*/
constructor(args) {
super(args);
const {
colorX,
colorZ,
resolution
} = args.attributes;
initialize() {

// ensure the entity has a render component
if (!this.entity.render) {
Expand All @@ -219,9 +202,9 @@ class Grid extends Script {
this.entity.render.meshInstances = [this._meshInstance];

// set the initial values
this.colorX = colorX ?? this.colorX;
this.colorZ = colorZ ?? this.colorZ;
this.resolution = resolution ?? this.resolution;
this.colorX = this._colorX;
this.colorZ = this._colorZ;
this.resolution = this._resolution;

// calculate half extents
this._set('uHalfExtents', this._calcHalfExtents(tmpVa));
Expand Down Expand Up @@ -258,10 +241,15 @@ class Grid extends Script {

/**
* @param {string} name - The name of the parameter.
* @param {Color|Vec2} value - The value of the parameter.
* @param {Color|Vec2|number} value - The value of the parameter.
* @private
*/
_set(name, value) {

if (!this._material) {
return;
}

if (value instanceof Color) {
this._material.setParameter(name, [value.r, value.g, value.b]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scene/shader-lib/chunks/gsplat/vert/gsplatOutput.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default /* glsl */`
#include "tonemappingPS"
#include "decodePS"
#if TONEMAP != NONE
#if GAMMA == SRGB
#include "decodePS"
#include "gamma2_2PS"
#else
#include "gamma1_0PS"
Expand Down

0 comments on commit fb14177

Please sign in to comment.