Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <reference path="typings/ue.d.ts">/>
- (function (global) {
- "use strict"
- const THREE = require( 'three' );
- function threeVertexToUEVertex( v ){
- return {
- X: v.x,
- Y: v.y,
- Z: v.z
- };
- }
- class ProceduralJSMesh extends Blueprint.Load('/Game/ProceduralBox').GeneratedClass {
- ctor() {
- // Subobject initialization, property initialization
- this.bAlwaysRelevant = true
- console.log( 'constructing procedural js mesh' );
- }
- ReceiveBeginPlay() {
- const geo = new THREE.TorusKnotGeometry(200, 40, 128, 24, 2, 3, 1);
- this.vertices = geo.vertices.map( function( vertex ){
- return threeVertexToUEVertex( vertex );
- });
- this.triangles = geo.faces.reduce( function( arr, f ){
- arr.push( f.c );
- arr.push( f.b );
- arr.push( f.a );
- return arr;
- }, [] );
- this.normals = geo.faces.reduce( function( arr, f ){
- arr.push( threeVertexToUEVertex( f.vertexNormals[ 0 ] ) );
- arr.push( threeVertexToUEVertex( f.vertexNormals[ 1 ] ) );
- arr.push( threeVertexToUEVertex( f.vertexNormals[ 2 ] ) );
- return arr;
- }, [] );
- this.uvs = geo.faceVertexUvs[ 0 ].reduce( function( arr, uvs ){
- uvs.forEach( function( vertex ){
- arr.push( {
- X: vertex.x,
- Y: vertex.y
- } );
- });
- return arr;
- }, [] );
- super.ReceiveBeginPlay();
- }
- }
- let MyActor_C = require('uclass')()(global,ProceduralJSMesh)
- let _ = require('lodash')
- function GetPC() {
- return GWorld.GetAllActorsOfClass(PlayerController).OutActors[0]
- }
- function main() {
- if (GWorld.IsServer()) {
- let actor = new MyActor_C(GWorld,{X:1})
- return function () {
- actor.DestroyActor()
- }
- } else {
- return function() {}
- }
- }
- try {
- module.exports = () => {
- let cleanup = null
- process.nextTick(() => cleanup = main());
- return () => cleanup()
- }
- }
- catch (e) {
- require('bootstrap')('generate')
- }
- })(this)
Advertisement
Add Comment
Please, Sign In to add comment