UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

120 lines 4.67 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { PointLight } from 'three'; import { iLightCommons } from '../object/iLightCommons'; import { uiColor, uiNumber, uiPanelContainer, uiSlider, uiToggle, uiVector } from 'uiconfig.js'; import { onChange3 } from 'ts-browser-helpers'; import { bindToValue } from '../../three'; /** * Extension of three.js PointLight with additional properties for serialization and UI * * Note - gltf serialization is handled by {@link GLTFLightExtrasExtension} */ let PointLight2 = class PointLight2 extends PointLight { _mapSizeChanged() { this.shadow.map?.dispose(); this.shadow.mapPass?.dispose(); this.shadow.map = null; this.shadow.mapPass = null; this.setDirty({ change: 'shadowMapSize' }); } _shadowCamUpdate(change) { this.shadow.camera.updateProjectionMatrix(); this.setDirty({ change }); } constructor(color, intensity, distance, decay) { super(color, intensity, distance, decay); this.assetType = 'light'; this.setDirty = iLightCommons.setDirty; this.refreshUi = iLightCommons.refreshUi; this.isPointLight2 = true; iLightCommons.upgradeLight.call(this); } autoScale() { console.warn('AutoScale not supported on Lights'); return this; } autoCenter() { console.warn('AutoCenter not supported on Lights'); return this; } /** * @deprecated use `this` instead */ get lightObject() { return this; } /** * @deprecated use `this` instead */ get modelObject() { return this; } }; __decorate([ uiToggle('Enabled'), onChange3('setDirty') ], PointLight2.prototype, "visible", void 0); __decorate([ uiColor('Color', (that) => ({ onChange: () => that.setDirty() })) ], PointLight2.prototype, "color", void 0); __decorate([ uiSlider('Intensity', [0, 30], 0.01), onChange3('setDirty') ], PointLight2.prototype, "intensity", void 0); __decorate([ uiNumber('Distance'), onChange3('setDirty') ], PointLight2.prototype, "distance", void 0); __decorate([ uiNumber('Decay'), onChange3('setDirty') ], PointLight2.prototype, "decay", void 0); __decorate([ uiNumber('Power'), onChange3('setDirty') ], PointLight2.prototype, "power", void 0); __decorate([ uiVector('Position', undefined, undefined, (that) => ({ onChange: () => that.setDirty() })) ], PointLight2.prototype, "position", void 0); __decorate([ uiToggle('Cast Shadow'), onChange3('setDirty') ], PointLight2.prototype, "castShadow", void 0); __decorate([ uiVector('Shadow Map Size'), bindToValue({ obj: 'shadow', key: 'mapSize', onChange: PointLight2.prototype._mapSizeChanged, onChangeParams: false }) ], PointLight2.prototype, "shadowMapSize", void 0); __decorate([ uiSlider('Shadow Bias', [-0.001, 0.001], 0.00001), bindToValue({ obj: 'shadow', key: 'bias', onChange: 'setDirty' }) ], PointLight2.prototype, "shadowBias", void 0); __decorate([ uiSlider('Shadow Radius', [0, 5], 0.01), bindToValue({ obj: 'shadow', key: 'radius', onChange: 'setDirty' }) ], PointLight2.prototype, "shadowRadius", void 0); __decorate([ uiNumber('Shadow Near'), bindToValue({ obj: 'shadow', key: ['camera', 'near'], onChange: PointLight2.prototype._shadowCamUpdate }) ], PointLight2.prototype, "shadowNear", void 0); __decorate([ uiNumber('Shadow Far'), bindToValue({ obj: 'shadow', key: ['camera', 'far'], onChange: PointLight2.prototype._shadowCamUpdate }) ], PointLight2.prototype, "shadowFar", void 0); __decorate([ uiNumber('Shadow Aspect'), bindToValue({ obj: 'shadow', key: 'aspect', onChange: PointLight2.prototype._shadowCamUpdate }) ], PointLight2.prototype, "shadowAspect", void 0); __decorate([ uiSlider('Shadow FOV', [1, 179], 1), bindToValue({ obj: 'shadow', key: 'fov', onChange: PointLight2.prototype._shadowCamUpdate }) ], PointLight2.prototype, "shadowFov", void 0); PointLight2 = __decorate([ uiPanelContainer('Point Light') ], PointLight2); export { PointLight2 }; //# sourceMappingURL=PointLight2.js.map