zdog实现三维蒸汽幽灵房屋效果代码
代码语言:html
所属分类:三维
代码描述:zdog实现三维蒸汽幽灵房屋效果代码,鼠标拖动可切换视角。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: #1B2838; color: #EEE; } .zdog-canvas { display: block; margin: 0 auto; cursor: move; } </style> </head> <body> <!-- partial:index.partial.html --> <canvas class="zdog-canvas" width="750" height="750"></canvas> <!-- partial --> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/zdog.dist.js"></script> <script > // namespace window.ZdogSpookyHouse = { wobbling: true, sceneY: 12, hillScale: 0.75, color: { deep: 'hsl(230, 60%, 40%)', dark: 'hsl(230, 60%, 50%)', darker: '#2a3a81', medium: 'hsl(230, 60%, 60%)', light: 'hsl(230, 60%, 70%)', pale: '#6D77AD', highlight: '#FFB', fog: 'hsla(230, 60%, 80%, 0.4)', paintjob: '#d59c55', } }; // ------------------------- bones ------------------------- // ZdogSpookyHouse.addBones = function( options ) { var TAU = Zdog.TAU; var lineX = 2; var color = ZdogSpookyHouse.color.light; var stroke = 1.3; var line = new Zdog.Shape({ addTo: options.addTo, path: [ { x: -lineX }, { x: lineX } ], closed: false, stroke: stroke, color: color, translate: { y: 12, z: -30 }, rotate: { y: TAU/16, z: TAU/16 }, }); var halfFemur = line.copy({ translate: { x: -6, y: 15, z: -28 }, rotate: { y: -TAU/8, z: TAU/8 }, }); var femurEnd = line.copy({ addTo: halfFemur, path: [ { x: 1, y: -1 }, { x: 0, y: 0 }, { x: 1, y: 1 }, ], closed: false, rotate: null, translate: { x: lineX }, }); halfFemur.copyGraph({ translate: { x: 1, y: 6, z: -31 }, rotate: { z: -TAU/8, x: TAU/8 }, scale: 0.75, }); line.copy({ scale: 0.25, translate: { y: 18, z: -26 }, rotate: { z: TAU/8 }, }); var fullFemur = halfFemur.copyGraph({ translate: { x: -9, y: 10, z: -30 }, rotate: { z: -TAU/16 }, }); femurEnd.copy({ addTo: fullFemur, scale: { x: -1 }, translate: { x: -lineX }, }); line.copy({ scale: 0.4, translate: { x: -12, y: 14, z: -28 }, rotate: { z: -TAU/16 }, }); }; // ------------------------- car & road ------------------------- // ZdogSpookyHouse.addCarRoad = function( options ) { var color = ZdogSpookyHouse.color; var TAU = Zdog.TAU; var roadRadius = 120; var roadSegmentCount = 40; var roadSegmentZ = 5; var roadSegmentX = (roadRadius + roadSegmentZ) * TAU / roadSegmentCount / 2; var roadSegmentPath = [ { x: -roadSegmentX + 1, z: roadSegmentZ }, { x: roadSegmentX - 1, z: roadSegmentZ }, { x: roadSegmentX, z: -roadSegmentZ }, { x: -roadSegmentX, z: -roadSegmentZ }, ]; for ( var i = 0; i < roadSegmentCount; i++ ) { var roadAngle = i/roadSegmentCount * TAU; new Zdog.Shape({ addTo: options.addTo, path: roadSegmentPath, translate: { x: Math.cos( roadAngle ) * roadRadius, z: Math.sin( roadAngle ) * roadRadius, }, rotate: { y: roadAngle + TAU/4 }, fill: true, stroke: 2, color: color.deep, }); } // car var bottomY = -1; var middleY = -2.5; var topY = -4.5; var outerZ = 2.5; var innerZ = 1.5; var grillX = -5; var hoodX = -4; var wipersX = -2; var windshieldX = -1; var roofX = 2; var trunkX = 4; var bumperX = 5; var driverPoints = { grill: new Zdog.Vector({ x: grillX, y: bottomY, z: outerZ }), hood: new Zdog.Vector({ x: hoodX, y: middleY, z: outerZ }), wipers: new Zdog.Vector({ x: wipersX, y: middleY, z: outerZ }), windshield: new Zdog.Vector({ x: windshieldX, y: topY, z: innerZ }), roof: new Zdog.Vector({ x: roofX, y: topY, z: innerZ }), trunk: new Zdog.Vector({ x: trunkX, y: middleY, z: outerZ }), bumper: new Zdog.Vector({ x: bumperX, y: bottomY, z: outerZ }), }; // copy to passenger points on other z side var passengerPoints = {}; for ( var pointName in driverPoints ) { var driverPoint = driverPoints[ pointName ]; passengerPoints[ pointName ] = driverPoint.copy().multiply({ z: -1 }); } var carRotor = new Zdog.Anchor({ addTo: options.addTo, }); var carAnchorY = -6; var carAnchor = new Zdog.Group({ addTo: carRotor, translate: { z: roadRadius - 0, y: carAnchorY }, scale: 1.2, updateSort: true, }); var carSide = new Zdog.Shape({ addTo: carAnchor, path: [ driverPoints.grill, driverPoints.hood, driverPoints.wipers, driverPoints.windshield, driverPoints.roof, driverPoints.trunk, driverPoints.bumper ], stroke: 2, fill: true, color: color.paintjob, }); carSide.copy({ scale: { z: -1 }, }); function getCarPanel( pointNameA, pointNameB, color ) { return carSide.copy({ path: [ driverPoints[ pointNameA ], driverPoints[ pointNameB ], passengerPoints[ pointNameB ], passengerPoints[ pointNameA ], ], color: color || carSide.color, }); } getCarPanel( 'grill', 'hood' ); // front grill getCarPanel( 'hood', 'wipers' ); // hood getCarPanel( 'wipers', 'windshield', color.medium ); // windshield getCarPanel( 'windshield', 'roof' ); // roof getCarPanel( 'roof', 'trunk', color.medium ); // back window getCarPanel( 'trunk', 'bumper' ); // back bumper var tireTranslate = new Zdog.Vector({ x: -3.5, z: outerZ, y: bottomY }); var tire = new Zdog.Ellipse({ addTo: carAnchor, diameter: 1.8, translate: tireTranslate, stroke: 2, fill: true, color: color.paintjob, }); tire.copy({ translate: tireTranslate.copy().multiply({ x: -1 }), }); tire.copy({ translate: tireTranslate.copy().multiply({ z: -1 }), }); tire.copy({ translate: tireTranslate.copy().multiply({ x: -1, z: -1 }), }); function animate( progress ) { carRotor.rotate.y = Zdog.easeInOut( progress/4 % 1 ) * TAU + TAU * 3/8; carAnchor.rotate.x = Math.sin( progress * TAU * 2 ) * 0.1; carAnchor.translate.y = Math.sin( progress * TAU * 1.5 ) * 2 + carAnchorY; } return { animate: animate, }; }; // ------------------------- cats ------------------------- // ZdogSpookyHouse.addCats = function( options ) { var TAU = Zdog.TAU; var color = ZdogSpookyHouse.color; var catScale = 1.1; var cat = new Zdog.Anchor({ addTo: options.addTo, translate: { z: -22, x: -28, y: -2 }, scale: catScale, rotate: { y: TAU/8 }, }); new Zdog.Cone({ addTo: cat, diameter: 1, length: 3, rotate: { x: TAU/4 }, stroke: 4 * catScale, color: color.deep, }); var catHead = new Zdog.Shape({ addTo: cat, translate: { y: -4 }, stroke: 5 * catScale, color: color.deep, }); var catEye = new Zdog.Shape({ addTo: catHead, translate: { x: -1, z: 1 }, stroke: 0.9 * catScale, color: color.highlight, }); catEye.copy({ translate: { x: 1, z: 1 }, }); var catEarPointA = { x: -1, y: 1 }; var catEarPointB = { x: -1, y: -1 }; var catEarPointC = { x: 1, y: 1 }; var catEarPointD = { x: 1, y: 1, z: -1 }; var catEar = new Zdog.Anchor({ addTo: catHead, scale: new Zdog.Vector({ x: 1, y: 1, z: 1.25 }), }); var catEarPanel = new Zdog.Shape({ addTo: catEar, path: [ catEarPointA, catEarPointB, catEarPointD ], translate: { x: -0.96, y: -1.5, z: 0 }, stroke: 0.6 * catScale, fill: true, color: color.deep, }); catEarPanel.copy({ path: [ catEarPointB, catEarPointC, catEarPointD ], }); catEar.copyGraph({ scale: catEar.scale.copy().multiply({ x: -1 }), }); // tail new Zdog.Shape({ addTo: cat, path: [ {}, { bezier: [ { x: 4, y: 0, z: -4 }, { x: 0, y: -3, z: 0 }, { x: 3, y: -5, z: -1 }, ]}, ], closed: false, translate: { z: -1 }, stroke: 0 * catScale, color: color.deep, }); cat.copyGraph({ translate: { z: -6, x: -42, y: -15 }, scale: catScale, rotate: { y: TAU/4 }, }); cat.copyGraph({ translate: { z: -30, x: -30, y: -2 }, scale: catScale, rotate: { y: TAU/4 }, }); }; // ------------------------- fogMonster ------------------------- // ZdogSpookyHouse.addFogMonster = function( options ) { var TAU = Zdog.TAU; var color = ZdogSpookyHouse.color; var radius = 54; var rotor = new Zdog.Anchor( options ); // segments var segmentCount = 74; var trailEndAngle = TAU * 4/8; var segments = []; for ( var i = 0; i < segmentCount; i++ ) { var alpha = i / segmentCount; var angle = alpha * trailEndAngle; var segment = new Zdog.Shape({ addTo: rotor, path: [ {}, { x: radius * TAU / segmentCount * 0.8 } ], stroke: 22 + 8 * -Math.cos( TAU/8 * ( 3 + alpha * 5 ) ), translate: { x: Math.sin( angle ) * radius, z: Math.cos( angle ) * radius, y: Math.sin( angle * 4 ) * 6, }, rotate: { y: alpha * -trailEndAngle }, color: color.fog, }); segments.push( segment ); } var monsterEye = new Zdog.Shape({ addTo: segments[0], translate: { x: -10, z: 8 }, color: color.deep, stroke: 3.5, }); monsterEye.copy({ translate: { x: -10, z: -8 }, }); new Zdog.Ellipse({ addTo: segments[0], translate: { x: -10, y: 4 }, quarters: 2, rotate: { z: TAU/4, y: TAU/4 }, closed: true, diameter: 8, stroke: false, fill: true, color: color.deep, }); function animate( progress ) { var rotorRY = rotor.rotate.y = progress * TAU/6; segments.forEach( function( segment, i ) { var alpha = i / segmentCount; var angle = alpha * trailEndAngle; segment.translate.y = Math.sin( (angle - rotorRY) * 4 ) * 6; }); } return { animate: animate, }; }; // ------------------------- addHouse ------------------------- // ZdogSpookyHouse.addHouse = function( options ) { var TAU = Zdog.TAU; var color = ZdogSpookyHouse.color; var eastWestWallRects = []; var southWallRects = []; function addEastWestWallRect( rect ) { eastWestWallRects.push( rect ); } function addSouthWallRect( rect ) { southWallRects.push( rect ); } var house = new Zdog.Anchor({ addTo: options.addTo, translate: { x: 0, y: -8, z: -6 }, }); var wallPanelOptions = { addTo: house, width: 12, height: 12, stroke: options.stroke, fill: true, backface: color.deep, }; var southWallPanelOptions = Object.assign( { color: color.light, }, wallPanelOptions ); // south wall, front door var frontDoorGroup = new Zdog.Group({ addTo: house, translate: { z: 24 }, }); addSouthWallRect( new Zdog.Rect( Object.assign( {}, southWallPanelOptions, { addTo: frontDoorGroup, }) ) ); new Zdog.Rect({ addTo: frontDoorGroup, width: 6, height: 8, translate: { y: 2 }, color: color.dark, fill: true, stroke: false, }); ZdogSpookyHouse.getWallPanel({ // south wall, 2nd floor wall: Object.assign( { translate: { y: -12, z: 24 } }, southWallPanelOptions ), pane: color.medium, wallRectCallback: addSouthWallRect, }); ZdogSpookyHouse.getWallPanel({ // 3rd floor, window on wall: Object.assign( { translate: { y: -24, z: 24 }, }, southWallPanelOptions ), pane: color.highlight, wallRectCallback: addSouthWallRect, }); var eastWallPanelOptions = Object.assign( { color: color.medium, rotate: { y: -TAU/4 }, }, wallPanelOptions ); var westWallPanelOptions = Object.assign( { color: color.medium, rotate: { y: TAU/4 }, }, wallPanelOptions ); // entrance side facing east var eastWallSquare = new Zdog.Rect( Object.assign( {}, eastWallPanelOptions, { translate: { x: 6, z: 18, }, })); addEastWestWallRect( eastWallSquare ); addEastWestWallRect( eastWallSquare.copy({ // 2nd floor translate: { x: 6, y: -12, z: 18, }, }) ); addEastWestWallRect( eastWallSquare.copy({ // 3rd floor translate: { x: 6, y: -24, z: 18, }, }) ); // entrance west var westWallSquare = eastWallSquare.copy({ translate: { x: -6, z: 18, }, rotate: { y: TAU/4 }, }); addEastWestWallRect( westWallSquare ); addEastWestWallRect( westWallSquare.copy({ // 2nd floor translate: { x: -6, y: -12, z: 18, }, }) ); addEastWestWallRect( westWallSquare.copy({ // 3rd floor translate: { x: -6, y: -24, z: 18, }, }) ); // entrance roof var entranceRoof = new Zdog.Anchor({ addTo: house, translate: { y: -36, z: 18 }, }); var entranceRoofPanel = new Zdog.Shape({ addTo: entranceRoof, path: [ { x: -8, y: 6 }, { x: 8, y: 6 }, { x: 4, y: -6, z: -4 }, { x: -4, y: -6, z: -4 }, ], translate: { z: 8 }, stroke: options.stroke, fill: true, color: color.dark, }); entranceRoofPanel.copy({ rotate: { y: TAU/4 }, translate: { x: -8 }, }); entranceRoofPanel.copy({ rotate: { y: TAU/2 }, translate: { z: -8 }, color: color.deep, }); entranceRoofPanel.copy({ rotate: { y: TAU * 3/4 }, translate: { x: 8 }, color: color.deep, }); // roof cap new Zdog.Rect({ addTo: entranceRoof, width: 8, height: 8, rotate: { x: -TAU/4 }, translate: { y: -6 }, stroke: options.stroke, fill: true, color: color.dark, }); // south east ZdogSpookyHouse.getWallPanel({ // 1st floor wall: Object.assign( {}, southWallPanelOptions, { translate: { x: 12, z: 12 }, }), pane: color.medium, wallRectCallback: addSouthWallRect, }); ZdogSpookyHouse.getWallPanel({ // 2nd floor wall: Object.assign( {}, southWallPanelOptions, { translate: { x: 12, y: -12, z: 12 }, }), pane: color.medium, wallRectCallback: addSouthWallRect, }); // south west ZdogSpookyHouse.getWallPanel({ // 1st floor wall: Object.assign( {}, southWallPanelOptions, { translate: { x: -12, z: 12 }, }), pane: color.medium, wallRectCallback: addSouthWallRect, }); ZdogSpookyHouse.getWallPanel({ // 2nd floor wall: Object.assign( {}, southWallPanelOptions, { translate: { x: -12, y: -12, z: 12 }, }), pane: color.medium, wallRectCallback: addSouthWallRect, }); // east side ZdogSpookyHouse.getWallPanel({ // 1st floor wall: Object.assign( {}, eastWallPanelOptions, { translate: { x: 18, z: 6, }, }), pane: color.dark, wallRectCallback: addEastWestWallRect, }); ZdogSpookyHouse.getWallPanel({ // 2nd floor wall: Object.assign( {}, eastWallPanelOptions, { translate: { x: 18, y: -12, z: 6, }, }), pane: color.dark, wallRectCallback: addEastWestWallRect, }); ZdogSpookyHouse.getWallPanel({ // 1st floor wall: Object.assign( {}, eastWallPanelOptions, { translate: { x: 18, z: -6, }, }), pane: color.dark, wallRectCallback: addEastWestWallRect, }); addEastWestWallRect( eastWallSquare.copy({ // 2nd floor, half wall width: 6, translate: { x: 18, y: -12, z: -3, }, }) ); var northWallSquare = eastWallSquare.copy({ width: 6, translate: { x: 15, z: -12, }, rotate: { y: TAU/2 }, color: color.dark, }); var northBigWindowWall = new Zdog.Shape({ addTo: house, path: [ { x: -4, y: 12 }, { x: -4, y: -6 }, { arc: [ { x: -4, y: -10 }, { x: 0, y: -10 }, ]}, { arc: [ { x: 4, y: -10 }, { x: 4, y: -6 }, ]}, { x: 4, y: 12 }, { x: 5, y: 12 }, { x: 5, y: -12 }, { x: -5, y: -12 }, { x: -5, y: 12 }, ], translate: { x: 7, y: -6, z: -12, }, stroke: options.stroke, color: color.dark, fill: true, }); // window division lines new Zdog.Shape({ addTo: northBigWindowWall, path: [ { move: { x: -4, y: -6 } }, { line: { x: 4, y: -6 } }, { move: { x: -4, y: 0 } }, { line: { x: 4, y: 0 } }, { move: { x: -4, y: 6 } }, { line: { x: 4, y: 6 } }, { move: { x: 0, y: -11 } }, { line: { x: 0, y: 12 } }, ], closed: false, stroke: 0.2, color: color.dark, }); northBigWindowWall.copyGraph({ translate: { x: -3, y: -6, z: -12, }, }); northBigWindowWall.copyGraph({ translate: { x: -13, y: -6, z: -12, }, }); northWallSquare.copy({ // bottom width: 36, height: 3, translate: { x: 0, y: 4.5, z: -12, }, color: color.dark, }); // west walls ZdogSpookyHouse.getWallPanel({ // 1st floor north west wall: Object.assign( {}, westWallPanelOptions, { translate: { x: -18, z: -6 }, }), pane: color.dark, wallRectCallback: addEastWestWallRect, }); ZdogSpookyHouse.getWallPanel({ // 2nd floor, north west wall: Object.assign( {}, westWallPanelOptions, { translate: { x: -18, y: -12, z: -6 }, }), wallRectCallback: addEastWestWallRect, }); ZdogSpookyHouse.getWallPanel({ // 1st floor, south west wall: Object.assign( {}, westWallPanelOptions, { translate: { x: -18, z: 6 }, }), pane: color.dark, wallRectCallback: addEastWestWallRect, }); ZdogSpookyHouse.getWallPanel({ // 2nd story west hanger wall: Object.assign( {}, westWallPanelOptions, { translate: { x: -24, y: -12, z: 6 }, }), pane: color.highlight, wallRectCallback: addEastWestWallRect, }); // hanger underside new Zdog.Rect({ addTo: house, width: 12, height: 6, translate: { x: -21, y: -6, z: 6, }, stroke: options.stroke, fill: true, color: color.deep, rotate: { x: TAU/4, z: TAU/4 }, }); var southWallSquare = northWallSquare.copy({ width: 6, rotate: null, translate: { x: -21, y: -12, z: 12, }, color: color.light, }); addSouthWallRect( southWallSquare ); northWallSquare.copy({ width: 6, translate: { x: -21, y: -12, }, }); // north side penthouse northWallSquare.copy({ width: 12, height: 18, translate: { x: -6, y: -27, z: -18 }, }); // east side penthouse new Zdog.Rect({ addTo: house, width: 12, height: 6, translate: { x: 0, y: -33, z: -12 }, rotate: { y: TAU/4 }, stroke: options.stroke, fill: true, color: color.medium, }); // custom new Zdog.Shape({ addTo: house, path: [ { z: 2, y: -3 }, { z: -6, y: -3 }, { z: -6, y: 9 }, { z: -2, y: 9 }, ], translate: { y: -27, z: -12 }, stroke: options.stroke, fill: true, color: color.medium, }); westWallSquare.copy({ height: 18, translate: { x: -12, y: -27, z: -12 }, }); southWallSquare.copy({ height: 6, width: 12, translate: { x: -6, y: -33, z: -6 }, }); // penthouse underside new Zdog.Rect({ addTo: house, width: 12, height: 6, translate: { x: -6, y: -18, z: -15 }, rotate: { x: TAU/4 }, stroke: options.stroke, fill: true, color: color.deep, }); // penthouse roof entranceRoof.copyGraph({ translate: { x: -6, y: -42, z: -12 }, }); var northEastTowerAnchor = new Zdog.Anchor({ addTo: house, translate: { x: 18, y: -18, z: -12 }, }); // north east tower var northEastTowerGroup = new Zdog.Group({ addTo: northEastTowerAnchor, }); new Zdog.Cylinder({ addTo: northEastTowerGroup, diameter: 12, length: 24, color: color.medium, backface: color.deep, rotate: { x: TAU/4 }, stroke: false, }); new Zdog.Cone({ addTo: northEastTowerAnchor, diameter: 16, length: 16, translate: { y: -12 }, rotate: { x: TAU/4 }, color: color.deep, stroke: false, }); var towerPane = new Zdog.Rect({ addTo: northEastTowerGroup, width: 2, height: 6, translate: { x: 5, y: -6 }, rotate: { y: -TAU/4 }, fill: true, stroke: false, color: color.dark, backface: false, }); towerPane.copy({ translate: { y: 6, z: -5 }, rotate: { y: TAU/2 }, }); // north west tower northEastTowerAnchor.copyGraph({ translate: { x: -18, y: -30, z: -6 }, rotate: { y: -TAU/4 }, scale: { x: -1 }, }); // south west corner roof var roofCornerPanel = new Zdog.Shape({ addTo: house, path: [ { x: -6, y: 6 }, { x: 8, y: 6 }, { x: 4, y: -6, z: -4 }, { x: -6, y: -6, z: -4 }, ], translate: { x: 12, y: -24, z: 14 }, stroke: options.stroke, fill: true, color: color.dark, }); roofCornerPanel.copy({ scale: { x: -1 }, translate: { x: 20, y: -24, z: 6 }, rotate: { y: -TAU/4 }, color: color.deep, }); // south east corner roof roofCornerPanel.copy({ scale: { x: -1 }, translate: { x: -18, y: -24, z: 14 }, }); roofCornerPanel.copy({ translate: { x: -26, y: -24, z: 6 }, rotate: { y: TAU/4 }, }); // south roof fill var roofHalfPanel = new Zdog.Shape({ addTo: house, path: [ { x: -3, y: 6 }, { x: 3, y: 6 }, { x: 3, y: -6, z: -4 }, { x: -3, y: -6, z: -4 }, ], translate: { x: -9, y: -24, z: 14 }, stroke: options.stroke, fill: true, color: color.dark, }); // east roof fill roofHalfPanel.copy({ rotate: { y: -TAU/4 }, translate: { x: 20, y: -24, z: -3 }, color: color.deep, }); // north roof fills roofHalfPanel.copy({ rotate: { y: -TAU/2 }, translate: { x: 9, y: -24, z: -14 }, color: color.deep, }); roofHalfPanel.copy({ rotate: { y: -TAU/2 }, translate: { x: 3, y: -24, z: -14 }, color: color.deep, }); // roof tops var roofTop = new Zdog.Anchor({ addTo: house, translate: { y: -30 }, }); var roofTopPanel = new Zdog.Rect({ addTo: roofTop, width: 12, height: 10, rotate: { x: -TAU/4 }, translate: { z: 5 }, stroke: options.stroke, fill: true, color: color.dark, }); roofTopPanel.copy({ width: 10, translate: { x: 11, z: 5 }, }); roofTopPanel.copy({ width: 10, translate: { x: 11, z: -5 }, }); roofTopPanel.copy({ translate: { x: -12, z: 5 }, }); roofTopPanel.copy({ width: 4, translate: { x: -20, z: 5 }, }); roofTopPanel.copy({ width: 6, translate: { x: 3, z: -5 }, }); roofTopPanel.copy({ height: 6, translate: { x: -6, z: -3 }, }); // ------------------------- porch ------------------------- // var porchFrameAnchor = new Zdog.Anchor({ addTo: house, translate: { y: 2 }, }); var porchFramePanel = new Zdog.Anchor({ addTo: porchFrameAnchor, translate: { x: 9, z: 30, }, }); // porch arch new Zdog.Shape({ addTo: porchFramePanel, path: [ { x: -3, y: 0 }, { arc: [ { x: -3, y: -3 }, { x: 0, y: -3 }, ]}, { arc: [ { x: 3, y: -3 }, { x: 3, y: 0 }, ]}, { x: 3, y: -3 }, { x: -3, y: -3 }, ], translate: { y: -3 }, fill: true, stroke: 1, color: color.deep, }); var porchFrameRect = new Zdog.Rect({ addTo: porchFramePanel, width: 6, height: 10, translate: { y: -1 }, stroke: 1, color: color.deep, }); porchFrameRect.copy({ height: 4, translate: { y: 2 }, }); porchFrameRect.copy({ width: 2, height: 4, translate: { y: 2 }, }); // south porchFramePanel.copyGraph({ translate: { x: 15, z: 30 }, }); porchFramePanel.copyGraph({ translate: { x: 21, z: 30 }, }); porchFramePanel.copyGraph({ translate: { x: -9, z: 30 }, }); // east side var eastPorchFramePanel = porchFramePanel.copyGraph({ translate: { x: 24, z: 27 }, rotate: { y: -TAU/4 }, }); eastPorchFramePanel.copyGraph({ translate: { x: 24, z: 21 }, }); eastPorchFramePanel.copyGraph({ translate: { x: 24, z: 15 }, }); eastPorchFramePanel.copyGraph({ translate: { x: 24, z: 9 }, }); eastPorchFramePanel.copyGraph({ translate: { x: 24, z: 3 }, }); // west side var westPorchFramePanel = porchFramePanel.copyGraph({ translate: { x: -12, z: 27 }, rotate: { y: TAU/4 }, }); westPorchFramePanel.copyGraph({ translate: { x: -12, z: 21 }, }); // porch roof, south var southPorchRoof = new Zdog.Shape({ addTo: house, path: [ { x: -12, y: 2 }, { x: 6, y: 2 }, { x: 6, y: 0, z: -6 }, { x: .........完整代码请登录后点击上方下载按钮下载查看
网友评论0