WireframeShaderMaterialComponent.re.ts 1008 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import * as RE from 'rogue-engine';
  2. import * as THREE from 'three';
  3. import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial.js'
  4. import { Wireframe } from 'three/examples/jsm/lines/Wireframe.js'
  5. import { WireframeGeometry2 } from 'three/examples/jsm/lines/WireframeGeometry2.js'
  6. export default class WireframeShaderMaterialComponent extends RE.Component {
  7. @RE.props.material() baseMaterial: THREE.Material
  8. awake() {
  9. }
  10. start() {
  11. let geometry = new WireframeGeometry2((this.object3d as any).geometry)
  12. const matLine = new LineMaterial({
  13. color: 0x4422ff,
  14. linewidth: 5,
  15. dashed: false,
  16. });
  17. matLine.resolution.set( window.innerWidth, window.innerHeight );
  18. const wireframe = new Wireframe(geometry, matLine)
  19. wireframe.computeLineDistances()
  20. wireframe.scale.set(1, 1, 1)
  21. this.object3d.add(wireframe);
  22. (this.object3d as any).material = this.baseMaterial
  23. }
  24. update() {
  25. }
  26. }
  27. RE.registerComponent(WireframeShaderMaterialComponent);