@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
70 lines (69 loc) • 2.36 kB
JavaScript
;
import { PointsMaterial } from "three";
import { FrontSide } from "three";
import { PrimitiveMatNode } from "./_Base";
import { ColorsController, ColorParamConfig } from "./utils/ColorsController";
import {
AdvancedCommonController,
AdvancedCommonParamConfig
} from "./utils/AdvancedCommonController";
import { TextureMapController, MapParamConfig } from "./utils/TextureMapController";
import {
TextureAlphaMapController,
AlphaMapParamConfig
} from "./utils/TextureAlphaMapController";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { FogParamConfig, UniformFogController } from "./utils/UniformsFogController";
import { DefaultFolderParamConfig } from "./utils/DefaultFolder";
import { TexturesFolderParamConfig } from "./utils/TexturesFolder";
import { AdvancedFolderParamConfig } from "./utils/AdvancedFolder";
import { PointsSizeController, PointsParamConfig } from "./utils/PointsSizeController";
import { MatType } from "../../poly/registers/nodes/types/Mat";
class PointsMatParamsConfig extends FogParamConfig(
AdvancedCommonParamConfig(
/* advanced */
AdvancedFolderParamConfig(
AlphaMapParamConfig(
MapParamConfig(
/* textures */
TexturesFolderParamConfig(
ColorParamConfig(PointsParamConfig(DefaultFolderParamConfig(NodeParamsConfig)))
)
)
)
)
)
) {
}
const ParamsConfig = new PointsMatParamsConfig();
export class PointsMatNode extends PrimitiveMatNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
this.controllers = {
colors: new ColorsController(this),
advancedCommon: new AdvancedCommonController(this),
alphaMap: new TextureAlphaMapController(this),
map: new TextureMapController(this),
pointsSize: new PointsSizeController(this),
uniformFog: new UniformFogController(this)
};
this.controllersList = Object.values(this.controllers);
}
static type() {
return MatType.POINTS;
}
createMaterial() {
return new PointsMaterial({
vertexColors: false,
side: FrontSide,
color: 16777215,
opacity: 1
});
}
async cook() {
this._material = this._material || this.createMaterial();
await Promise.all(this.controllersPromises(this._material));
this.setMaterial(this._material);
}
}