defineGeometry(boat) {
        const copiedBoat = JSON.parse(JSON.stringify(boat));
        this.boat = {
            width: copiedBoat.width,
            height: copiedBoat.height,
            length: copiedBoat.length,
            frames: copiedBoat.frames,
        };
        Object.keys(copiedBoat).forEach((key) => {
            if (['width', 'height', 'length', 'frames'].indexOf(key) > -1) {
                return;
            }
            this.boat[key] = applyOffsets(this.boat, copiedBoat[key], key);
        });

        let parts = [];

        // Outer mesh
        parts = parts.concat(this.splitCurve(this.boat.aftBeam, this.boat.aftChine));
        parts = parts.concat(this.splitCurve(this.boat.foreBeam, this.boat.foreChine));
        parts = parts.concat(this.splitCurve(this.boat.foreChine, this.boat.foreKeel));
        parts = parts.concat(this.splitCurve(this.boat.aftChine, this.boat.aftKeel));
        parts = parts.concat(this.splitCurve(this.boat.aftBeamEdge, this.boat.aftGunEdge));
        parts = parts.concat(this.splitCurve(this.boat.foreBeamEdge, this.boat.foreGunEdge));

        // Define new boat for inner mesh.
        const innerBoat = JSON.parse(JSON.stringify(boat));
        innerBoat.width -= 1;
        innerBoat.height -= 1;
        innerBoat.length -= 1;

        Object.keys(innerBoat).forEach((key) => {
            if (['width', 'height', 'length', 'frames'].indexOf(key) > -1) {
                return;
            }
            innerBoat[key] = applyOffsets(innerBoat, innerBoat[key], key);
        });
        // We add on to all the top y values to offset the -1 in height.
        // This will make it so that our trim later on will be perfectly horizontal.
        innerBoat.aftBeam.start[1] += 1;
        innerBoat.aftBeam.end[1] += 1;
        innerBoat.foreBeam.start[1] += 1;
        innerBoat.foreBeam.end[1] += 1;
        innerBoat.aftBeamEdge.start[1] += 1;
        innerBoat.aftBeamEdge.end[1] += 1;
        innerBoat.foreBeamEdge.start[1] += 1;
        innerBoat.foreBeamEdge.end[1] += 1;

        // Add inner mesh.
        parts = parts.concat(this.splitCurve(innerBoat.aftBeam, innerBoat.aftChine));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeam, innerBoat.foreChine));
        parts = parts.concat(this.splitCurve(innerBoat.foreChine, innerBoat.foreKeel));
        parts = parts.concat(this.splitCurve(innerBoat.aftChine, innerBoat.aftKeel));
        parts = parts.concat(this.splitCurve(innerBoat.aftBeamEdge, innerBoat.aftGunEdge));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeamEdge, innerBoat.foreGunEdge));

        // Add trim (The part that attaches the inner boat to the outer boat)
        parts = parts.concat(this.splitCurve(innerBoat.aftBeam, this.boat.aftBeam));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeam, this.boat.foreBeam));
        parts = parts.concat(this.splitCurve(innerBoat.aftBeamEdge, this.boat.aftBeamEdge));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeamEdge, this.boat.foreBeamEdge));

        // Draw mesh.
        const firstElement = parts.pop();
        const initialFace = this.drawFace(firstElement);
        const faces = [];
        for (let i = 0; i < parts.length; i ++) {
            faces.push(this.drawFace(parts[i]));
        }

        // Merge faces
        faces.forEach((face) => {
            initialFace.merge(face);
        });

        initialFace.mergeVertices();
        initialFace.uvsNeedUpdate = true;

        const mirror = initialFace.clone();
        mirror.scale(-1, 1, 1);
        mirror.mergeVertices();
        mirror.uvsNeedUpdate = true;
        initialFace.merge(mirror);
        initialFace.name = 'boat-mesh';
        return initialFace;
    }
// For mirror, there is a copy function, we'll need to do it after a merge of half the boat.
For mirror, there is a copy function, we'll need to do it after a merge of half the boat.
For mirror there is a copy function we ' ll need to do it after a merge of half the boat .
defineGeometry(boat) {
        const copiedBoat = JSON.parse(JSON.stringify(boat));
        this.boat = {
            width: copiedBoat.width,
            height: copiedBoat.height,
            length: copiedBoat.length,
            frames: copiedBoat.frames,
        };
        Object.keys(copiedBoat).forEach((key) => {
            if (['width', 'height', 'length', 'frames'].indexOf(key) > -1) {
                return;
            }
            this.boat[key] = applyOffsets(this.boat, copiedBoat[key], key);
        });
        let parts = [];
        parts = parts.concat(this.splitCurve(this.boat.aftBeam, this.boat.aftChine));
        parts = parts.concat(this.splitCurve(this.boat.foreBeam, this.boat.foreChine));
        parts = parts.concat(this.splitCurve(this.boat.foreChine, this.boat.foreKeel));
        parts = parts.concat(this.splitCurve(this.boat.aftChine, this.boat.aftKeel));
        parts = parts.concat(this.splitCurve(this.boat.aftBeamEdge, this.boat.aftGunEdge));
        parts = parts.concat(this.splitCurve(this.boat.foreBeamEdge, this.boat.foreGunEdge));
        const innerBoat = JSON.parse(JSON.stringify(boat));
        innerBoat.width -= 1;
        innerBoat.height -= 1;
        innerBoat.length -= 1;
        Object.keys(innerBoat).forEach((key) => {
            if (['width', 'height', 'length', 'frames'].indexOf(key) > -1) {
                return;
            }
            innerBoat[key] = applyOffsets(innerBoat, innerBoat[key], key);
        });
        innerBoat.aftBeam.start[1] += 1;
        innerBoat.aftBeam.end[1] += 1;
        innerBoat.foreBeam.start[1] += 1;
        innerBoat.foreBeam.end[1] += 1;
        innerBoat.aftBeamEdge.start[1] += 1;
        innerBoat.aftBeamEdge.end[1] += 1;
        innerBoat.foreBeamEdge.start[1] += 1;
        innerBoat.foreBeamEdge.end[1] += 1;
        parts = parts.concat(this.splitCurve(innerBoat.aftBeam, innerBoat.aftChine));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeam, innerBoat.foreChine));
        parts = parts.concat(this.splitCurve(innerBoat.foreChine, innerBoat.foreKeel));
        parts = parts.concat(this.splitCurve(innerBoat.aftChine, innerBoat.aftKeel));
        parts = parts.concat(this.splitCurve(innerBoat.aftBeamEdge, innerBoat.aftGunEdge));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeamEdge, innerBoat.foreGunEdge));
        parts = parts.concat(this.splitCurve(innerBoat.aftBeam, this.boat.aftBeam));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeam, this.boat.foreBeam));
        parts = parts.concat(this.splitCurve(innerBoat.aftBeamEdge, this.boat.aftBeamEdge));
        parts = parts.concat(this.splitCurve(innerBoat.foreBeamEdge, this.boat.foreBeamEdge));
        const firstElement = parts.pop();
        const initialFace = this.drawFace(firstElement);
        const faces = [];
        for (let i = 0; i < parts.length; i ++) {
            faces.push(this.drawFace(parts[i]));
        }
        faces.forEach((face) => {
            initialFace.merge(face);
        });
        initialFace.mergeVertices();
        initialFace.uvsNeedUpdate = true;
        const mirror = initialFace.clone();
        mirror.scale(-1, 1, 1);
        mirror.mergeVertices();
        mirror.uvsNeedUpdate = true;
        initialFace.merge(mirror);
        initialFace.name = 'boat-mesh';
        return initialFace;
    }
defineGeometry ( boat ) { const copiedBoat = JSON . parse ( JSON . stringify ( boat ) ) ; this . boat = { width : copiedBoat . width , height : copiedBoat . height , length : copiedBoat . length , frames : copiedBoat . frames , } ; Object . keys ( copiedBoat ) . forEach ( ( key ) => { if ( [ 'width' , 'height' , 'length' , 'frames' ] . indexOf ( key ) > - 1 ) { return ; } this . boat [ key ] = applyOffsets ( this . boat , copiedBoat [ key ] , key ) ; } ) ; let parts = [ ] ; parts = parts . concat ( this . splitCurve ( this . boat . aftBeam , this . boat . aftChine ) ) ; parts = parts . concat ( this . splitCurve ( this . boat . foreBeam , this . boat . foreChine ) ) ; parts = parts . concat ( this . splitCurve ( this . boat . foreChine , this . boat . foreKeel ) ) ; parts = parts . concat ( this . splitCurve ( this . boat . aftChine , this . boat . aftKeel ) ) ; parts = parts . concat ( this . splitCurve ( this . boat . aftBeamEdge , this . boat . aftGunEdge ) ) ; parts = parts . concat ( this . splitCurve ( this . boat . foreBeamEdge , this . boat . foreGunEdge ) ) ; const innerBoat = JSON . parse ( JSON . stringify ( boat ) ) ; innerBoat . width -= 1 ; innerBoat . height -= 1 ; innerBoat . length -= 1 ; Object . keys ( innerBoat ) . forEach ( ( key ) => { if ( [ 'width' , 'height' , 'length' , 'frames' ] . indexOf ( key ) > - 1 ) { return ; } innerBoat [ key ] = applyOffsets ( innerBoat , innerBoat [ key ] , key ) ; } ) ; innerBoat . aftBeam . start [ 1 ] += 1 ; innerBoat . aftBeam . end [ 1 ] += 1 ; innerBoat . foreBeam . start [ 1 ] += 1 ; innerBoat . foreBeam . end [ 1 ] += 1 ; innerBoat . aftBeamEdge . start [ 1 ] += 1 ; innerBoat . aftBeamEdge . end [ 1 ] += 1 ; innerBoat . foreBeamEdge . start [ 1 ] += 1 ; innerBoat . foreBeamEdge . end [ 1 ] += 1 ; parts = parts . concat ( this . splitCurve ( innerBoat . aftBeam , innerBoat . aftChine ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . foreBeam , innerBoat . foreChine ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . foreChine , innerBoat . foreKeel ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . aftChine , innerBoat . aftKeel ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . aftBeamEdge , innerBoat . aftGunEdge ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . foreBeamEdge , innerBoat . foreGunEdge ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . aftBeam , this . boat . aftBeam ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . foreBeam , this . boat . foreBeam ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . aftBeamEdge , this . boat . aftBeamEdge ) ) ; parts = parts . concat ( this . splitCurve ( innerBoat . foreBeamEdge , this . boat . foreBeamEdge ) ) ; const firstElement = parts . pop ( ) ; const initialFace = this . drawFace ( firstElement ) ; const faces = [ ] ; for ( let i = 0 ; i < parts . length ; i ++ ) { faces . push ( this . drawFace ( parts [ i ] ) ) ; } faces . forEach ( ( face ) => { initialFace . merge ( face ) ; } ) ; initialFace . mergeVertices ( ) ; initialFace . uvsNeedUpdate = true ; const mirror = initialFace . clone ( ) ; mirror . scale ( - 1 , 1 , 1 ) ; mirror . mergeVertices ( ) ; mirror . uvsNeedUpdate = true ; initialFace . merge ( mirror ) ; initialFace . name = 'boat-mesh' ; return initialFace ; }
For mirror, there is a copy function, we'll need to do it after a merge of half the boat.
For mirror there is a copy function we ' ll need to do it after a merge of half the boat .
// Outer mesh // Define new boat for inner mesh. // We add on to all the top y values to offset the -1 in height. // This will make it so that our trim later on will be perfectly horizontal. // Add inner mesh. // Add trim (The part that attaches the inner boat to the outer boat) // Draw mesh. // Merge faces