Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///<reference path='easeljs.d.ts'/>
- var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
- };
- var MouseTarget = (function (_super) {
- __extends(MouseTarget, _super);
- function MouseTarget(tag) {
- _super.call(this);
- this.tag = tag;
- this.mouseEnabled = true;
- this.cursor = 'pointer';
- }
- return MouseTarget;
- })(createjs.Shape); //class
- ///<reference path='easeljs.d.ts'/>
- ///<reference path='mousetarget.ts'/>
- //Mdodified with new default settings
- var SliderCB = (function (_super) {
- __extends(SliderCB, _super);
- function SliderCB(width, height, tag, bgndColor) {
- _super.call(this);
- this.width = width;
- this.height = height;
- this.value = 0;
- this.trackHeight = 6;
- this.font = 'bold 12px Arial';
- this.tag = 0;
- this.multiplier = 1;
- this.min = 0;
- this.max = 10;
- this.color1 = '#bbbbbb';
- this.color2 = '#eeeeee';
- this.trackColor1 = '#0063b5';
- this.trackColor2 = '#3d95e4';
- this.prefix = '';
- this.postfix = '';
- this.thumbRadius = 8;
- this.dp = 0;
- this.showZeroPostfix = false;
- this.showValue = true;
- this.labelAlign = 'center';
- this.style = 0;
- //this.thumbRadius = 0.4 * this.height;
- this.tag = tag;
- var ms = new MouseTarget(0);
- if (!bgndColor) {
- bgndColor = '#ffffff';
- }
- ms.graphics.beginFill(bgndColor).drawRect(0, 0, this.width, this.height);
- this.addChild(ms);
- ms.addEventListener('mousedown', this.doTargetMouse);
- ms.addEventListener('pressmove', this.doTargetMouse);
- ms.addEventListener('pressup', this.doTargetMouse);
- // ms.mouseEnabled = true;
- // ms.cursor = 'pointer';
- this.gauge = new createjs.Shape();
- this.addChild(this.gauge);
- this.thumb = new createjs.Shape();
- this.thumb.y = 0.5 * this.height;
- this.addChild(this.thumb);
- this.thumb.mouseEnabled = false;
- this.gauge.mouseEnabled = false;
- this.drawThumb();
- this.drawGauge(0);
- this.valueLabel = new createjs.Text("", this.font, "#0000000");
- this.valueLabel.textAlign = 'left';
- this.valueLabel.x = 0;
- this.valueLabel.y = -10;
- this.addChild(this.valueLabel);
- this.valueLabel.mouseEnabled = false;
- }
- SliderCB.prototype.drawThumb = function () {
- var g = this.thumb.graphics;
- g.clear();
- if (this.style == 0) {
- g.ss(1).s('#333333');
- g.rf([this.color1, this.color2, this.color1], [0.4, 0.8, 1], 0, 0, 0, 0, 0, this.thumbRadius);
- g.dc(0, 0, this.thumbRadius).ef();
- } else {
- g.ss(1).s('#333333').lf(['#f0f0f0', '#c0c0c0'], [0, 1], 0, 0, 0, 2 * this.thumbRadius);
- g.dr(-this.thumbRadius, -this.thumbRadius, 2 * this.thumbRadius, 2 * this.thumbRadius).ef();
- }
- };
- SliderCB.prototype.drawGauge = function (px) {
- var y = (this.height - this.trackHeight) / 2;
- var g = this.gauge.graphics;
- g.clear();
- g.ss(1).s('#9a9a9a');
- g.beginFill('#ffffff');
- g.drawRect(0, y, this.width, this.trackHeight);
- g.ef();
- if (px > 0) {
- g.lf([this.trackColor1, this.trackColor2, this.trackColor1], [0, 0.5, 1], 0, y, 0, y + this.trackHeight);
- g.drawRect(0, y, px, this.trackHeight);
- }
- };
- SliderCB.prototype.mouseToValue = function (px) {
- var delta = (this.max - this.min) / this.width;
- var n = this.min + px * delta;
- if (n > this.max) {
- n = this.max;
- } else if (n < this.min) {
- n = this.min;
- }
- return n;
- };
- SliderCB.prototype.valueToMouse = function () {
- var delta = (this.max - this.min) / this.width;
- //var n: number = this.min + px * delta;
- var px = (this.value - this.min) / delta;
- return px;
- };
- SliderCB.prototype.doText = function () {
- if (this.showValue) {
- var pf;
- if (this.showZeroPostfix || this.value > 0) {
- pf = this.postfix;
- } else {
- pf = '';
- }
- if (this.dp == 0) {
- this.valueLabel.text = this.prefix + (this.multiplier * Math.round(this.value)).toFixed() + pf;
- } else {
- this.valueLabel.text = this.prefix + this.value.toFixed(this.dp) + pf;
- }
- } else {
- this.valueLabel.text = this.prefix;
- }
- if (this.labelAlign === 'left') {
- //this.valueLabel.regX = 0;
- } else if (this.labelAlign === 'center') {
- //this.valueLabel.regX = 0.5 * this.valueLabel.getMeasuredWidth();
- } else if (this.labelAlign === 'right') {
- //this.valueLabel.regX = this.valueLabel.getMeasuredWidth();
- }
- };
- SliderCB.prototype.doTargetMouse = function (e) {
- var p = e.target.parent;
- var px;
- px = (e.target.globalToLocal(e.stageX, e.stageY)).x;
- p.setPixelValue(px, e.type);
- //if (e.type == "pressup") {
- //canUpdate = false
- //}
- //else {
- //canUpdate = true
- //}
- };
- SliderCB.prototype.getValue = function () {
- return this.value;
- };
- SliderCB.prototype.setValue = function (value) {
- if (this.dp == 0)
- this.value = Math.round(value);
- else
- this.value = value;
- var px = this.valueToMouse();
- this.drawGauge(px);
- if (px < this.thumbRadius) {
- this.thumb.x = this.thumbRadius;
- } else if (px > this.width - this.thumbRadius) {
- this.thumb.x = this.width - this.thumbRadius;
- } else {
- this.thumb.x = px;
- }
- this.doText();
- };
- SliderCB.prototype.setPixelValue = function (px, type) {
- if (px > this.width) {
- px = this.width;
- } else if (px < 0) {
- px = 0;
- }
- this.value = this.mouseToValue(px);
- this.drawGauge(px);
- if (px < this.thumbRadius) {
- this.thumb.x = this.thumbRadius;
- } else if (px > this.width - this.thumbRadius) {
- this.thumb.x = this.width - this.thumbRadius;
- } else {
- this.thumb.x = px;
- }
- this.doText();
- if (this.fcallback) {
- this.fcallback(this.tag, this.value, type);
- } else {
- stage.update();
- }
- };
- SliderCB.prototype.setTrackHeight = function (value) {
- this.trackHeight = value;
- var px = this.valueToMouse();
- this.drawGauge(px);
- };
- SliderCB.prototype.setThumbRadius = function (value) {
- this.thumbRadius = value;
- this.drawThumb();
- };
- SliderCB.prototype.setLabelAlign = function (value) {
- this.labelAlign = value;
- this.valueLabel.textAlign = value;
- if (value === 'left') {
- this.valueLabel.x = 0;
- } else if (value === 'center') {
- this.valueLabel.x = 0.5 * this.width;
- } else if (value === 'right') {
- this.valueLabel.x = this.width;
- }
- };
- SliderCB.prototype.setTextOffsetY = function (value) {
- this.valueLabel.y = value;
- };
- SliderCB.prototype.setTextFont = function (fs) {
- this.valueLabel.font = fs;
- };
- SliderCB.prototype.setTag = function (value) {
- this.getChildAt(0).tag = value;
- };
- SliderCB.prototype.setFont = function (value, color) {
- this.valueLabel.font = value;
- if (color) {
- this.valueLabel.color = color;
- }
- };
- SliderCB.prototype.setColors = function (c1, c2) {
- this.color1 = c1;
- this.color2 = c2;
- };
- SliderCB.prototype.setTrackColor = function (c1, c2) {
- this.trackColor1 = c1;
- this.trackColor2 = c2;
- };
- SliderCB.prototype.doEnabled = function (value) {
- this.getChildAt(0).mouseEnabled = value;
- };
- SliderCB.prototype.setText = function (s) {
- this.valueLabel.text = s;
- };
- SliderCB.prototype.addCallback = function (f) {
- this.fcallback = f;
- };
- SliderCB.prototype.setStyle = function (n, thumbRad) {
- this.style = n;
- if (thumbRad) {
- this.thumbRadius = thumbRad;
- }
- this.drawThumb();
- };
- return SliderCB;
- })(createjs.Container);
- ///<reference path='easeljs.d.ts'/>
- ///<reference path='mousetarget.ts'/>
- var PJRadioButton = (function (_super) {
- __extends(PJRadioButton, _super);
- function PJRadioButton(width, height, tag, caption, bgndColor) {
- _super.call(this);
- this.width = width;
- this.height = height;
- this.bgndColor = '#ffffff';
- this.btn = new createjs.Shape();
- this.check = new createjs.Shape();
- this.font = 'bold 14px Arial';
- this.color1 = '#cccccc';
- this.color2 = '#fefefe';
- this.checked = false;
- if (bgndColor) {
- this.bgndColor = bgndColor;
- }
- this.btnRadius = 0.3 * this.height;
- this.mt = new MouseTarget(tag);
- this.addChild(this.mt);
- this.addChild(this.btn);
- this.btn.x = this.btnRadius;
- this.btn.y = 0.5 * this.height;
- this.drawBtnBgnd();
- this.btn.mouseEnabled = false;
- this.addChild(this.check);
- this.check.x = this.btnRadius;
- this.check.y = 0.5 * this.height;
- this.check.visible = false;
- this.check.graphics.beginFill('#000000').drawCircle(0, 0, 0.5 * this.btnRadius).endFill();
- this.check.mouseEnabled = false;
- if (caption) {
- this.captionLabel = new createjs.Text(caption, this.font);
- this.captionLabel.regY = 0.5 * this.captionLabel.getMeasuredHeight();
- this.captionLabel.x = 2.5 * this.btnRadius;
- this.captionLabel.y = 0.5 * this.height;
- this.addChild(this.captionLabel);
- if (caption.indexOf('\n') != -1) {
- //var a = caption.split('\n');
- //var w = Math.max(a[0].getMeasuredWidth(), a[1].getMeasuredWidth());
- //w = this.width;
- } else {
- this.width = this.captionLabel.x + this.captionLabel.getMeasuredWidth();
- }
- this.captionLabel.mouseEnabled = false;
- }
- this.mt.graphics.beginFill(this.bgndColor).drawRect(0, 0, this.width, this.height).endFill();
- }
- PJRadioButton.prototype.addMouseEvent = function (f) {
- this.getChildAt(0).addEventListener('mousedown', f);
- };
- PJRadioButton.prototype.drawBtnBgnd = function () {
- var g = this.btn.graphics;
- g.clear();
- g.setStrokeStyle(1, 1, 1, 1, true).beginStroke('#9a9a9a');
- g.beginRadialGradientFill([this.color2, this.color1], [0.25, 1], 0, 0, 0, 0, 0, this.btnRadius);
- g.drawCircle(0, 0, this.btnRadius).endFill();
- };
- PJRadioButton.prototype.setCheck = function (value) {
- this.check.visible = value;
- this.checked = value;
- };
- PJRadioButton.prototype.doEnabled = function (value) {
- var bgnd = this.getChildAt(0);
- bgnd.mouseEnabled = value;
- if (value)
- this.alpha = 1;
- else
- this.alpha = 0.5;
- };
- PJRadioButton.prototype.setFont = function (value, offset) {
- this.captionLabel.font = value;
- this.captionLabel.regY = 0.5 * this.captionLabel.getMeasuredHeight();
- if (offset) {
- this.captionLabel.y = 0.5 * this.height + offset;
- } else {
- this.captionLabel.y = 0.5 * this.height;
- }
- this.width = this.captionLabel.x + this.captionLabel.getMeasuredWidth();
- var mt = this.getChildAt(0);
- mt.graphics.c().beginFill(this.bgndColor).drawRect(0, 0, this.width, this.height).endFill();
- };
- PJRadioButton.prototype.setWidth = function (w) {
- this.width = w;
- this.mt.graphics.clear().beginFill(this.bgndColor).drawRect(0, 0, this.width, this.height).endFill();
- };
- return PJRadioButton;
- })(createjs.Container); //class
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- var Wood = (function () {
- function Wood() {
- }
- Wood.jtCornerMT = 0;
- Wood.jtDoubleMT = 2;
- Wood.jtGroovedFrameMT = 1;
- Wood.jtHaunchedMT = 3;
- Wood.jtLooseWedgedMT = 4;
- Wood.jtStoppedMT = 5;
- Wood.jtThroughMT = 6;
- Wood.jtTwinMT1 = 7;
- Wood.jtTwinMT2 = 8;
- Wood.jtWedgedMT = 9;
- Wood.jtDowel1 = 10;
- Wood.jtDowel2 = 11;
- Wood.jtDowel3 = 12;
- Wood.jtDowelButt = 36;
- Wood.jtCornerBridle = 14;
- Wood.jtTBridle = 15;
- Wood.jtLap = 21;
- Wood.jtCornerHalving = 17;
- Wood.jtTHalving = 18;
- Wood.jtCrossHalving = 19;
- Wood.jtDovetailHalving = 20;
- Wood.jtThroughDovetail = 16;
- Wood.jtLappedDovetail = 22;
- Wood.jtFinger = 23;
- Wood.jtStoppedHousing = 24;
- Wood.jtThroughHousing = 25;
- Wood.jtEdgeToEdgeButt = 26;
- Wood.jtMitredButt1 = 27;
- Wood.jtMitredButt2 = 28;
- Wood.jtSplinedEdgeToEdge = 29;
- Wood.jtSplinedMitre = 30;
- Wood.jtSquareEndButt = 31;
- Wood.jtSquareEndButt2 = 32;
- Wood.jtTongueGroove = 33;
- Wood.jtGroove = 38;
- Wood.jtBiscuit = 35;
- Wood.jtButtRub = 13;
- Wood.jtDwrGroove = 37;
- Wood.jtRebate = 34;
- Wood.clfFace = 0;
- Wood.clfEndGrain = 1;
- Wood.clfHole = 2;
- Wood.clfDowel = 3;
- Wood.clfDowelHole = 4;
- Wood.clfPanel = 5;
- return Wood;
- })();
- var Vertex = (function () {
- function Vertex(x, y, z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- return Vertex;
- })();
- var Matrix = (function () {
- function Matrix() {
- this.m = new Array(3);
- this.m[0] = [1, 0, 0];
- this.m[1] = [0, 1, 0];
- this.m[2] = [0, 0, 1];
- }
- return Matrix;
- })();
- var RotationMatrix = (function (_super) {
- __extends(RotationMatrix, _super);
- function RotationMatrix(deg, style) {
- _super.call(this);
- var a = deg * Math.PI / 180;
- var c = Math.cos(a);
- var s = Math.sin(a);
- if (style == 0) {
- this.m[1][1] = c;
- this.m[1][2] = -s;
- this.m[2][1] = s;
- this.m[2][2] = c;
- } else if (style == 1) {
- this.m[0][0] = c;
- this.m[0][2] = s;
- this.m[2][0] = -s;
- this.m[2][2] = c;
- } else {
- this.m[0][0] = c;
- this.m[0][1] = s;
- this.m[1][0] = -s;
- this.m[1][1] = c;
- }
- }
- return RotationMatrix;
- })(Matrix);
- //************************************************************************************************************
- var BaseJoint = (function () {
- function BaseJoint() {
- this.vertexList = [];
- this.faceList = [];
- this.xOffset = 0;
- this.yOffset = 0;
- }
- BaseJoint.prototype.draw = function (g) {
- };
- BaseJoint.prototype.rotate = function (ax, ay) {
- };
- BaseJoint.prototype.explode = function (g, dx) {
- };
- return BaseJoint;
- })();
- var eyePos = 1000;
- var zoom = 0.75 * eyePos;
- var clEdge = '#5b3a3a';
- var clDowelEdge = '#8C8056';
- var lightPos = new Vertex(-1000, -1000, -1000);
- //************************************************************************************************************
- //p1 is next vertex anticlockwise from p0
- //p2 -> vertex clockwise from P0
- //Calculates the cosine of the angle between the unit normal to the face and a
- //unit vector from the face to the eye position. Dot product of these vectors.
- //If -90 <= angle <= 90 then the cosine is +ve and the face is visible
- function visible3DFace(p0, p1, p2) {
- var a = (p1.y - p0.y) * (p2.z - p0.z) - (p2.y - p0.y) * (p1.z - p0.z);
- var b = -((p1.x - p0.x) * (p2.z - p0.z) - (p2.x - p0.x) * (p1.z - p0.z));
- var c = (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
- return (-p0.x * a - p0.y * b + c * (-eyePos - p0.z)) > 0;
- }
- //************************************************************************************************************
- //p1 is next vertex anticlockwise from p0
- //p2 -> vertex clockwise from P0
- //Calculates the cosine of the angle between the unit normal to the face and a
- //unit vector from the face to the light position. Dot product of these vectors
- function getFaceColor(p0, p1, p2, baseColor) {
- var res = '';
- var a = (p1.y - p0.y) * (p2.z - p0.z) - (p2.y - p0.y) * (p1.z - p0.z);
- var b = -((p1.x - p0.x) * (p2.z - p0.z) - (p2.x - p0.x) * (p1.z - p0.z));
- var c = (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
- var magN = Math.sqrt(a * a + b * b + c * c);
- var magV = 1 / Math.sqrt((lightPos.x - p0.x) * (lightPos.x - p0.x) + (lightPos.y - p0.y) * (lightPos.y - p0.y) + (lightPos.z - p0.z) * (lightPos.z - p0.z));
- magN = magV / magN;
- var cs = (lightPos.x - p0.x) * a * magN + (lightPos.y - p0.y) * b * magN + c * (lightPos.z - p0.z) * magN;
- if (cs < -1)
- cs = -1;
- else if (cs > 1)
- cs = 1;
- var n = Math.floor(Math.acos(cs) * 180 / Math.PI * 0.67);
- var r, g;
- switch (baseColor) {
- case Wood.clfFace:
- if (n <= 90) {
- r = 240 - n;
- g = 180 - n;
- b = 90 - n;
- } else {
- r = 240 - n;
- g = 180 - n;
- b = 0;
- }
- break;
- case Wood.clfEndGrain:
- r = 0xff - n;
- g = 0xca - n;
- b = 0x9f - n;
- break;
- case Wood.clfDowel:
- r = 255 - n;
- g = 225 - n;
- b = 120;
- break;
- case Wood.clfDowelHole:
- r = 225 - n;
- g = 160 - n;
- b = 0;
- break;
- case Wood.clfPanel:
- r = 255 - n;
- g = 220 - n;
- b = 150 - n;
- break;
- default:
- //holes
- r = 190 - n;
- g = 120 - n;
- b = 0;
- }
- res = 'RGB(' + r.toFixed() + ', ' + g.toFixed() + ', ' + b.toFixed() + ')';
- return res;
- }
- //************************************************************************************************************
- //Projection of 3D point on the viewing plane
- function get2dPoint(p, xOff, yOff) {
- var r = zoom / (eyePos + p.z);
- return new createjs.Point(r * p.x + xOff, r * p.y + yOff);
- }
- function get2dPointEx(p, xOff, yOff, zoomScale) {
- var r = zoomScale / (eyePos + p.z);
- return new createjs.Point(r * p.x + xOff, r * p.y + yOff);
- }
- //************************************************************************************************************
- function matMultiply(m1, m2) {
- var mat = new Matrix();
- var h, j, k;
- var n;
- for (h = 0; h < 3; h++) {
- for (j = 0; j < 3; j++) {
- n = 0;
- for (k = 0; k < 3; k++) {
- n = n + m1.m[h][k] * m2.m[k][j];
- }
- mat.m[h][j] = n;
- }
- }
- return mat;
- }
- //************************************************************************************************************
- //Transform a vertex, p with the matrix, mat
- function applyMatrix(p, mat) {
- var x = (p.x * mat.m[0][0] + p.y * mat.m[1][0] + p.z * mat.m[2][0]);
- var y = (p.x * mat.m[0][1] + p.y * mat.m[1][1] + p.z * mat.m[2][1]);
- var z = (p.x * mat.m[0][2] + p.y * mat.m[1][2] + p.z * mat.m[2][2]);
- return new Vertex(x, y, z);
- }
- //************************************************************************************************************
- //Return a joint name from the joint ID
- function getJointName(nID) {
- var res = '';
- switch (nID) {
- case Wood.jtBiscuit:
- res = 'Biscuit joint';
- break;
- case Wood.jtButtRub:
- res = 'Butt rub joint';
- break;
- case Wood.jtCornerBridle:
- res = 'Corner Bridle joint';
- break;
- case Wood.jtCornerHalving:
- res = 'Corner Halving joint';
- break;
- case Wood.jtCornerMT:
- res = 'Corner mortise & tenon';
- break;
- case Wood.jtCrossHalving:
- res = 'Cross Halving joint';
- break;
- case Wood.jtDoubleMT:
- res = 'Forked mortise + tenon';
- break;
- case Wood.jtDovetailHalving:
- res = 'Dovetail Halving joint';
- break;
- case Wood.jtDowel1:
- res = 'Dowel joint(1)';
- break;
- case Wood.jtDowel2:
- res = 'Dowel joint(2)';
- break;
- case Wood.jtDowel3:
- res = 'Dowel joint(3)';
- break;
- case Wood.jtDowelButt:
- res = 'Dowelled butt joint';
- break;
- case Wood.jtEdgeToEdgeButt:
- res = 'Edge to edge butt joint';
- break;
- case Wood.jtFinger:
- res = 'Finger joint';
- break;
- case Wood.jtGroove:
- res = 'Groove (1)';
- break;
- case Wood.jtGroovedFrameMT:
- res = 'Grooved-frame mortise & tenon';
- break;
- case Wood.jtHaunchedMT:
- res = 'Haunched mortise & tenon';
- break;
- case Wood.jtLap:
- res = 'Lap joint';
- break;
- case Wood.jtLappedDovetail:
- res = 'Lapped Dovetail';
- break;
- case Wood.jtLooseWedgedMT:
- res = 'Loose wedged mortise & tenon';
- break;
- case Wood.jtMitredButt1:
- res = 'Mitred butt joint(1)';
- break;
- case Wood.jtMitredButt2:
- res = 'Mitred butt joint(2)';
- break;
- case Wood.jtSplinedEdgeToEdge:
- res = 'Splined edge to edge';
- break;
- case Wood.jtSplinedMitre:
- res = 'Splined mitre joint';
- break;
- case Wood.jtSquareEndButt:
- res = 'Square ended butt joint(1)';
- break;
- case Wood.jtSquareEndButt2:
- res = 'Square ended butt joint(2)';
- break;
- case Wood.jtStoppedHousing:
- res = 'Stopped Housing';
- break;
- case Wood.jtStoppedMT:
- res = 'Stopped mortise & tenon';
- break;
- case Wood.jtTBridle:
- res = 'T-Bridle joint';
- break;
- case Wood.jtTHalving:
- res = 'T-Halving joint';
- break;
- case Wood.jtThroughDovetail:
- res = 'Through Dovetail';
- break;
- case Wood.jtThroughHousing:
- res = 'Through Housing';
- break;
- case Wood.jtThroughMT:
- res = 'Through mortise & tenon';
- break;
- case Wood.jtTongueGroove:
- res = 'Tongue+Groove joint';
- break;
- case Wood.jtTwinMT1:
- res = 'Twin mortise & tenon(1)';
- break;
- case Wood.jtTwinMT2:
- res = 'Twin mortise & tenon(2)';
- break;
- case Wood.jtWedgedMT:
- res = 'Wedged mortise + tenon';
- break;
- case Wood.jtDwrGroove:
- res = 'Groove (2)';
- break;
- case Wood.jtRebate:
- res = 'Rebate joint';
- break;
- default:
- res = '';
- }
- return res;
- }
- //***************************************************************************************************************
- //Return path + filename for the ajax_* file with the joint info
- function getInfoFilename(nID) {
- var res = '';
- switch (nID) {
- case Wood.jtBiscuit:
- res = 'ajax_e2e_biscuit.html';
- break;
- case Wood.jtButtRub:
- res = 'ajax_butt_rub.html';
- break;
- case Wood.jtCornerBridle:
- res = 'ajax_bridle_corner.html';
- break;
- case Wood.jtCornerHalving:
- res = 'ajax_halving_corner.html';
- break;
- case Wood.jtCornerMT:
- res = 'ajax_corner_mt.html';
- break;
- case Wood.jtCrossHalving:
- res = 'ajax_halving_cross.html';
- break;
- case Wood.jtDoubleMT:
- res = 'ajax_double_mt.html';
- break;
- case Wood.jtDovetailHalving:
- res = 'ajax_halving_tee.html';
- break;
- case Wood.jtDowel1:
- res = 'ajax_dowel.html';
- break;
- case Wood.jtDowel2:
- res = 'ajax_dowel.html';
- break;
- case Wood.jtDowel3:
- res = 'ajax_dowel.html';
- break;
- case Wood.jtDowelButt:
- res = 'ajax_dowel_butt.html';
- break;
- case Wood.jtEdgeToEdgeButt:
- res = 'ajax_e2e_butt.html';
- break;
- case Wood.jtFinger:
- res = 'ajax_finger.html';
- break;
- case Wood.jtGroove:
- res = 'ajax_rebate.html';
- break;
- case Wood.jtGroovedFrameMT:
- res = 'ajax_grooved_frame_mt.html';
- break;
- case Wood.jtHaunchedMT:
- res = 'ajax_haunched_mt.html';
- break;
- case Wood.jtLap:
- res = 'ajax_lap.html';
- break;
- case Wood.jtLappedDovetail:
- res = 'ajax_lapped_dovetail.html';
- break;
- case Wood.jtLooseWedgedMT:
- res = 'ajax_loose_wedged_mt.html';
- break;
- case Wood.jtMitredButt1:
- res = 'ajax_mitre_butt.html';
- break;
- case Wood.jtMitredButt2:
- res = 'ajax_mitre_butt.html';
- break;
- case Wood.jtSplinedEdgeToEdge:
- res = 'ajax_e2e_splined.html';
- break;
- case Wood.jtSplinedMitre:
- res = 'ajax_mitre_splined.html';
- break;
- case Wood.jtSquareEndButt:
- res = 'ajax_sq_end_butt.html';
- break;
- case Wood.jtSquareEndButt2:
- res = 'ajax_sq_end_butt.html';
- break;
- case Wood.jtStoppedHousing:
- res = 'ajax_stopped_housing.html';
- break;
- case Wood.jtStoppedMT:
- res = 'ajax_stopped_mt.html';
- break;
- case Wood.jtTBridle:
- res = 'ajax_bridle_tee.html';
- break;
- case Wood.jtTHalving:
- res = 'ajax_halving_tee.html';
- break;
- case Wood.jtThroughDovetail:
- res = 'ajax_through_dovetail.html';
- break;
- case Wood.jtThroughHousing:
- res = 'ajax_through_housing.html';
- break;
- case Wood.jtThroughMT:
- res = 'ajax_through_mt.html';
- break;
- case Wood.jtTongueGroove:
- res = 'ajax_e2e_grooved.html';
- break;
- case Wood.jtTwinMT1:
- res = 'ajax_twin_mt.html';
- break;
- case Wood.jtTwinMT2:
- res = 'ajax_twin_mt.html';
- break;
- case Wood.jtWedgedMT:
- res = 'ajax_loose_wedged_mt.html';
- break;
- case Wood.jtDwrGroove:
- res = 'ajax_drawer_groove.html';
- break;
- case Wood.jtRebate:
- res = 'ajax_rebate.html';
- break;
- default:
- res = '';
- }
- res = '/programmes/woodjoints/pages/' + res;
- return res;
- }
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- var Thumbnail = (function (_super) {
- __extends(Thumbnail, _super);
- function Thumbnail(tn, jointID, hotspot) {
- _super.call(this);
- this.jointID = jointID;
- this.hotspot = hotspot;
- this.selRect = new createjs.Shape();
- var bgnd = new createjs.Shape();
- bgnd.graphics.f('#ffffff').drawRect(0, 0, 72, 50);
- this.addChild(bgnd);
- this.addChild(tn);
- bgnd.addEventListener('mousedown', this.doClick);
- //#445DF4
- //#81A1FB
- this.selRect.graphics.s('#445DF4').dr(0, 0, 70, 50);
- this.addChild(this.selRect);
- this.selRect.visible = false;
- }
- Thumbnail.prototype.doClick = function (e) {
- var p = e.target.parent;
- if (p.fcallback) {
- p.fcallback(p.jointID, p.hotspot);
- }
- };
- Thumbnail.prototype.addCallback = function (f) {
- this.fcallback = f;
- };
- Thumbnail.prototype.setSelected = function (value) {
- this.selRect.visible = value;
- };
- return Thumbnail;
- })(createjs.Container); //class
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- var ButtRubJoint = (function (_super) {
- __extends(ButtRubJoint, _super);
- function ButtRubJoint(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = dx;
- this.vertexList = new Array(24);
- this.initJoint();
- this.initFaceList();
- }
- ButtRubJoint.prototype.initJoint = function () {
- var dy = 100;
- this.vertexList[0] = new Vertex(this.xShift + 200, -dy, 70);
- this.vertexList[1] = new Vertex(this.xShift + 200, -dy, 100);
- this.vertexList[2] = new Vertex(this.xShift, -dy, 100);
- this.vertexList[3] = new Vertex(this.xShift, -dy, 70);
- this.vertexList[4] = new Vertex(this.xShift + 200, dy, 70);
- this.vertexList[5] = new Vertex(this.xShift + 200, dy, 100);
- this.vertexList[6] = new Vertex(this.xShift, dy, 100);
- this.vertexList[7] = new Vertex(this.xShift, dy, 70);
- this.vertexList[8] = new Vertex(-this.xShift, -dy, -200);
- this.vertexList[9] = new Vertex(-this.xShift, -dy, 100);
- this.vertexList[10] = new Vertex(-this.xShift - 30, -dy, 100);
- this.vertexList[11] = new Vertex(-this.xShift - 30, -dy, -200);
- this.vertexList[12] = new Vertex(-this.xShift, dy, -200);
- this.vertexList[13] = new Vertex(-this.xShift, dy, 100);
- this.vertexList[14] = new Vertex(-this.xShift - 30, dy, 100);
- this.vertexList[15] = new Vertex(-this.xShift - 30, dy, -200);
- this.vertexList[16] = new Vertex(this.xShift, -dy, -this.xShift + 25);
- this.vertexList[17] = new Vertex(this.xShift + 50, -dy, -this.xShift + 70);
- this.vertexList[18] = new Vertex(this.xShift, -dy, -this.xShift + 70);
- this.vertexList[19] = new Vertex(this.xShift, dy, -this.xShift + 25);
- this.vertexList[20] = new Vertex(this.xShift + 50, dy, -this.xShift + 70);
- this.vertexList[21] = new Vertex(this.xShift, dy, -this.xShift + 70);
- this.vertexList[22] = new Vertex(this.xShift + 50, -dy, -this.xShift + 25);
- this.vertexList[23] = new Vertex(this.xShift + 50, dy, -this.xShift + 25);
- };
- ButtRubJoint.prototype.initFaceList = function () {
- this.faceList = new Array(17);
- this.faceList[0] = [1, 0, 4, 5];
- this.faceList[1] = [3, 2, 6, 7];
- this.faceList[2] = [0, 1, 2, 3];
- this.faceList[3] = [0, 3, 7, 4];
- this.faceList[4] = [4, 7, 6, 5];
- this.faceList[5] = [8, 12, 13, 9];
- this.faceList[6] = [11, 10, 14, 15];
- this.faceList[7] = [8, 9, 10, 11];
- this.faceList[8] = [8, 11, 15, 12];
- this.faceList[9] = [12, 15, 14, 13];
- this.faceList[10] = [16, 19, 20, 17];
- this.faceList[11] = [17, 20, 21, 18];
- this.faceList[12] = [16, 18, 21, 19];
- this.faceList[13] = [16, 17, 18];
- this.faceList[14] = [19, 21, 20];
- this.faceList[15] = [1, 5, 6, 2];
- this.faceList[16] = [10, 9, 13, 14];
- };
- ButtRubJoint.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var p2d;
- g.clear();
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- switch (nface) {
- case 2:
- case 4:
- case 7:
- case 9:
- case 13:
- case 14:
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- break;
- default:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- }
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- };
- //***************************************************************************************************************
- ButtRubJoint.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- var mat = matMultiply(mx, my);
- this.initJoint();
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], mat);
- }
- if (rx >= 0) {
- if (ry > 90) {
- this.dlist = [5, 11, 12, 13, 1, 15, 2, 6, 7, 16]; //<<<<<<<<<<<<<<<
- } else if (ry >= 0) {
- this.dlist = [0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9];
- } else if (ry >= -90) {
- this.dlist = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 10, 11, 12, 13, 14];
- } else {
- this.dlist = [5, 7, 16, 3, 10, 12, 13, 11, 15, 1, 2, 0];
- }
- } else if (rx < 0) {
- if (ry > 90) {
- this.dlist = [3, 11, 12, 14, 15, 4, 1, 5, 6, 9, 16];
- } else if (ry >= 0) {
- this.dlist = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9];
- } else if (ry >= -90) {
- this.dlist = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 10, 11, 12, 13, 14];
- } else {
- this.dlist = [5, 9, 16, 3, 10, 11, 12, 13, 14, 0, 1, 4, 15];
- }
- }
- this.drawFaces(g);
- };
- ButtRubJoint.prototype.explode = function (g, dx) {
- this.xShift = dx;
- this.draw(g);
- };
- return ButtRubJoint;
- })(BaseJoint);
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- var ThroughDovetail = (function (_super) {
- __extends(ThroughDovetail, _super);
- function ThroughDovetail(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = dx;
- this.vertexList = new Array(48);
- this.initJoint();
- this.initFaceList();
- }
- //private initJoint() {
- //var dz:number = -15;
- ////left
- //this.vertexList[0] = new Vertex( -150, -50, dz);
- //this.vertexList[1] = new Vertex(30, -50, dz);
- //this.vertexList[2] = new Vertex(30, -30, dz);
- //this.vertexList[3] = new Vertex(0, -30, dz);
- //this.vertexList[4] = new Vertex(0, 40, dz);
- //this.vertexList[5] = new Vertex(30, 40, dz);
- //this.vertexList[6] = new Vertex(30, 60, dz);
- //this.vertexList[7] = new Vertex(0, 60, dz);
- //this.vertexList[8] = new Vertex(0, 130, dz);
- //this.vertexList[9] = new Vertex(30, 130, dz);
- //this.vertexList[10] = new Vertex(30, 150, dz);
- //this.vertexList[11] = new Vertex( -150, 150, dz);
- //
- //this.vertexList[12] = new Vertex( -150, -50, -dz);
- //this.vertexList[13] = new Vertex(30, -50, -dz);
- //this.vertexList[14] = new Vertex(30, -25, -dz);
- //this.vertexList[15] = new Vertex(0, -25, -dz);
- //this.vertexList[16] = new Vertex(0, 35, -dz);
- //this.vertexList[17] = new Vertex(30, 35, -dz);
- //this.vertexList[18] = new Vertex(30, 65, -dz);
- //this.vertexList[19] = new Vertex(0, 65, -dz);
- //this.vertexList[20] = new Vertex(0, 125, -dz);
- //this.vertexList[21] = new Vertex(30, 125, -dz);
- //this.vertexList[22] = new Vertex(30, 150, -dz);
- //this.vertexList[23] = new Vertex( -150, 150, -dz);
- //
- ////socket half of Dovetail
- //this.vertexList[24] = new Vertex(30 + this.xShift, -50, 15);
- //this.vertexList[25] = new Vertex(30 + this.xShift, -25, 15);
- //this.vertexList[26] = new Vertex(30 + this.xShift, -30, -15);
- //this.vertexList[27] = new Vertex(30 + this.xShift, 40, -15);
- //this.vertexList[28] = new Vertex(30 + this.xShift, 35, 15);
- //this.vertexList[29] = new Vertex(30 + this.xShift, 65, 15);
- //this.vertexList[30] = new Vertex(30 + this.xShift, 60, -15);
- //this.vertexList[31] = new Vertex(30 + this.xShift, 130, -15);
- //this.vertexList[32] = new Vertex(30 + this.xShift, 125, 15);
- //this.vertexList[33] = new Vertex(30 + this.xShift, 150, 15);
- //this.vertexList[34] = new Vertex(30 + this.xShift, 150, 150);
- //this.vertexList[35] = new Vertex(30 + this.xShift, -50, 150);
- //
- //this.vertexList[36] = new Vertex(this.xShift, -50, 15);
- //this.vertexList[37] = new Vertex(this.xShift, -25, 15);
- //this.vertexList[38] = new Vertex(this.xShift, -30, -15);
- //this.vertexList[39] = new Vertex(this.xShift, 40, -15);
- //this.vertexList[40] = new Vertex(this.xShift, 35, 15);
- //this.vertexList[41] = new Vertex(this.xShift, 65, 15);
- //this.vertexList[42] = new Vertex(this.xShift, 60, -15);
- //this.vertexList[43] = new Vertex(this.xShift, 130, -15);
- //this.vertexList[44] = new Vertex(this.xShift, 125, 15);
- //this.vertexList[45] = new Vertex(this.xShift, 150, 15);
- //this.vertexList[46] = new Vertex(this.xShift, 150, 150);
- //this.vertexList[47] = new Vertex(this.xShift, -50, 150);
- //}
- ThroughDovetail.prototype.initJoint = function () {
- var dz = -15;
- var dx = 0.5 * this.xShift;
- //left
- this.vertexList[0] = new Vertex(-150 - dx, -50, dz);
- this.vertexList[1] = new Vertex(30 - dx, -50, dz);
- this.vertexList[2] = new Vertex(30 - dx, -30, dz);
- this.vertexList[3] = new Vertex(0 - dx, -30, dz);
- this.vertexList[4] = new Vertex(0 - dx, 40, dz);
- this.vertexList[5] = new Vertex(30 - dx, 40, dz);
- this.vertexList[6] = new Vertex(30 - dx, 60, dz);
- this.vertexList[7] = new Vertex(0 - dx, 60, dz);
- this.vertexList[8] = new Vertex(0 - dx, 130, dz);
- this.vertexList[9] = new Vertex(30 - dx, 130, dz);
- this.vertexList[10] = new Vertex(30 - dx, 150, dz);
- this.vertexList[11] = new Vertex(-150 - dx, 150, dz);
- this.vertexList[12] = new Vertex(-150 - dx, -50, -dz);
- this.vertexList[13] = new Vertex(30 - dx, -50, -dz);
- this.vertexList[14] = new Vertex(30 - dx, -25, -dz);
- this.vertexList[15] = new Vertex(0 - dx, -25, -dz);
- this.vertexList[16] = new Vertex(0 - dx, 35, -dz);
- this.vertexList[17] = new Vertex(30 - dx, 35, -dz);
- this.vertexList[18] = new Vertex(30 - dx, 65, -dz);
- this.vertexList[19] = new Vertex(0 - dx, 65, -dz);
- this.vertexList[20] = new Vertex(0 - dx, 125, -dz);
- this.vertexList[21] = new Vertex(30 - dx, 125, -dz);
- this.vertexList[22] = new Vertex(30 - dx, 150, -dz);
- this.vertexList[23] = new Vertex(-150 - dx, 150, -dz);
- //socket half of Dovetail
- this.vertexList[24] = new Vertex(30 + dx, -50, 15);
- this.vertexList[25] = new Vertex(30 + dx, -25, 15);
- this.vertexList[26] = new Vertex(30 + dx, -30, -15);
- this.vertexList[27] = new Vertex(30 + dx, 40, -15);
- this.vertexList[28] = new Vertex(30 + dx, 35, 15);
- this.vertexList[29] = new Vertex(30 + dx, 65, 15);
- this.vertexList[30] = new Vertex(30 + dx, 60, -15);
- this.vertexList[31] = new Vertex(30 + dx, 130, -15);
- this.vertexList[32] = new Vertex(30 + dx, 125, 15);
- this.vertexList[33] = new Vertex(30 + dx, 150, 15);
- this.vertexList[34] = new Vertex(30 + dx, 150, 150);
- this.vertexList[35] = new Vertex(30 + dx, -50, 150);
- this.vertexList[36] = new Vertex(dx, -50, 15);
- this.vertexList[37] = new Vertex(dx, -25, 15);
- this.vertexList[38] = new Vertex(dx, -30, -15);
- this.vertexList[39] = new Vertex(dx, 40, -15);
- this.vertexList[40] = new Vertex(dx, 35, 15);
- this.vertexList[41] = new Vertex(dx, 65, 15);
- this.vertexList[42] = new Vertex(dx, 60, -15);
- this.vertexList[43] = new Vertex(dx, 130, -15);
- this.vertexList[44] = new Vertex(dx, 125, 15);
- this.vertexList[45] = new Vertex(dx, 150, 15);
- this.vertexList[46] = new Vertex(dx, 150, 150);
- this.vertexList[47] = new Vertex(dx, -50, 150);
- };
- ThroughDovetail.prototype.initFaceList = function () {
- this.faceList = new Array(30);
- this.faceList[0] = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
- this.faceList[1] = [0, 1, 13, 12];
- this.faceList[2] = [0, 12, 23, 11];
- this.faceList[3] = [10, 11, 23, 22];
- this.faceList[4] = [2, 14, 13, 1];
- this.faceList[5] = [2, 3, 15, 14];
- this.faceList[6] = [4, 5, 17, 16];
- this.faceList[7] = [6, 18, 17, 5];
- this.faceList[8] = [6, 7, 19, 18];
- this.faceList[9] = [8, 9, 21, 20];
- this.faceList[10] = [10, 22, 21, 9];
- this.faceList[11] = [4, 16, 15, 3];
- this.faceList[12] = [8, 20, 19, 7];
- this.faceList[13] = [35, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34];
- this.faceList[14] = [36, 24, 35, 47];
- this.faceList[15] = [33, 45, 46, 34];
- this.faceList[16] = [37, 25, 24, 36];
- this.faceList[17] = [38, 26, 25, 37];
- this.faceList[18] = [39, 27, 26, 38];
- this.faceList[19] = [27, 39, 40, 28];
- this.faceList[20] = [41, 29, 28, 40];
- this.faceList[21] = [42, 30, 29, 41];
- this.faceList[22] = [43, 31, 30, 42];
- this.faceList[23] = [31, 43, 44, 32];
- this.faceList[24] = [45, 33, 32, 44];
- this.faceList[25] = [36, 47, 46, 45];
- this.faceList[26] = [40, 39, 38, 37];
- this.faceList[27] = [44, 43, 42, 41];
- this.faceList[28] = [34, 46, 47, 35];
- this.faceList[29] = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
- };
- ThroughDovetail.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var ap;
- g.clear();
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- switch (nface) {
- case 2:
- case 4:
- case 7:
- case 10:
- case 11:
- case 12:
- case 16:
- case 18:
- case 20:
- case 22:
- case 24:
- case 28:
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp().ef().es();
- break;
- case 25:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- if (this.xShift > 0) {
- g.f(color).ss(1, 2).s(color);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp().ef();
- ap = get2dPoint(this.vertexList[37], this.xOffset, this.yOffset);
- g.s(clEdge).mt(ap.x, ap.y).lt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y);
- ap = get2dPoint(this.vertexList[40], this.xOffset, this.yOffset);
- g.mt(ap.x, ap.y);
- ap = get2dPoint(this.vertexList[41], this.xOffset, this.yOffset);
- g.lt(ap.x, ap.y);
- ap = get2dPoint(this.vertexList[44], this.xOffset, this.yOffset);
- g.mt(ap.x, ap.y).lt(a[3].x, a[3].y).es();
- } else {
- g.f(color).s(clEdge).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp().ef().es();
- }
- break;
- case 26:
- case 27:
- color = getFaceColor(this.vertexList[47], this.vertexList[46], this.vertexList[36], Wood.clfFace);
- g.f(color).ss(1, 2).s(color);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp().ef();
- g.s(clEdge).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y);
- break;
- default:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- }
- };
- //***************************************************************************************************************
- ThroughDovetail.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- var mat = matMultiply(mx, my);
- this.initJoint();
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], mat);
- }
- if (rx >= 0) {
- if (ry > 90) {
- this.dlist = [11, 12, 9, 21, 27, 6, 17, 26, 29, 25, 14, 28, 1, 2];
- } else if (ry >= 0) {
- this.dlist = [25, 24, 20, 16, 5, 26, 19, 6, 8, 27, 23, 9, 0, 3, 15, 18, 22, 2];
- } else if (ry >= -90) {
- this.dlist = [25, 16, 20, 24, 11, 12, 5, 4, 26, 18, 19, 6, 7, 8, 27, 23, 9, 10, 22, 13, 0, 15, 3]; //<<<<<<<<<<<<<<<<<<
- } else {
- this.dlist = [12, 11, 9, 27, 6, 10, 21, 7, 17, 26, 4, 29, 13, 14, 28, 1, 25];
- }
- } else if (rx < 0) {
- if (ry > 90) {
- this.dlist = [11, 12, 5, 26, 19, 8, 27, 23, 29, 25, 3, 2, 15, 28];
- } else if (ry >= 0) {
- this.dlist = [25, 14, 16, 20, 24, 9, 27, 21, 8, 6, 26, 17, 5, 22, 18, 1, 2, 0];
- } else if (ry >= -90) {
- this.dlist = [25, 26, 27, 12, 11, 24, 20, 16, 9, 10, 21, 8, 7, 6, 17, 5, 4, 22, 18, 13, 1, 14, 0];
- } else {
- this.dlist = [26, 11, 12, 5, 4, 19, 8, 7, 29, 23, 27, 25, 28, 10, 3, 15, 13];
- }
- }
- this.drawFaces(g);
- };
- ThroughDovetail.prototype.explode = function (g, dx) {
- this.xShift = dx;
- this.draw(g);
- };
- return ThroughDovetail;
- })(BaseJoint);
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- var LapJoint = (function (_super) {
- __extends(LapJoint, _super);
- function LapJoint(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = dx;
- this.vertexList = new Array(24);
- this.initJoint();
- this.initFaceList();
- }
- LapJoint.prototype.initJoint = function () {
- var dy = 100;
- this.vertexList[0] = new Vertex(this.xShift, -dy, 200);
- this.vertexList[1] = new Vertex(this.xShift, -dy, 30);
- this.vertexList[2] = new Vertex(this.xShift + 20, -dy, 30);
- this.vertexList[3] = new Vertex(this.xShift + 20, -dy, 0);
- this.vertexList[4] = new Vertex(this.xShift + 30, -dy, 0);
- this.vertexList[5] = new Vertex(this.xShift + 30, -dy, 200);
- this.vertexList[6] = new Vertex(this.xShift, dy, 200);
- this.vertexList[7] = new Vertex(this.xShift, dy, 30);
- this.vertexList[8] = new Vertex(this.xShift + 20, dy, 30);
- this.vertexList[9] = new Vertex(this.xShift + 20, dy, 0);
- this.vertexList[10] = new Vertex(this.xShift + 30, dy, 0);
- this.vertexList[11] = new Vertex(this.xShift + 30, dy, 200);
- this.vertexList[12] = new Vertex(-this.xShift - 200, -dy, 30);
- this.vertexList[13] = new Vertex(-this.xShift - 200, -dy, 0);
- this.vertexList[14] = new Vertex(-this.xShift + 20, -dy, 0);
- this.vertexList[15] = new Vertex(-this.xShift + 20, -dy, 30);
- this.vertexList[16] = new Vertex(-this.xShift - 200, dy, 30);
- this.vertexList[17] = new Vertex(-this.xShift - 200, dy, 0);
- this.vertexList[18] = new Vertex(-this.xShift + 20, dy, 0);
- this.vertexList[19] = new Vertex(-this.xShift + 20, dy, 30);
- //graain
- this.vertexList[20] = new Vertex(this.xShift, -dy, 0);
- this.vertexList[21] = new Vertex(this.xShift, dy, 0);
- this.vertexList[22] = new Vertex(this.xShift + 30, -dy, 30);
- this.vertexList[23] = new Vertex(this.xShift + 30, dy, 30);
- };
- LapJoint.prototype.initFaceList = function () {
- this.faceList = new Array(14);
- this.faceList[0] = [0, 6, 7, 1];
- this.faceList[1] = [1, 7, 8, 2];
- this.faceList[2] = [2, 8, 9, 3];
- this.faceList[3] = [3, 9, 10, 4];
- this.faceList[4] = [5, 4, 10, 11];
- this.faceList[5] = [0, 1, 2, 3, 4, 5];
- this.faceList[6] = [6, 11, 10, 9, 8, 7];
- this.faceList[7] = [13, 17, 18, 14];
- this.faceList[8] = [15, 14, 18, 19];
- this.faceList[9] = [12, 13, 14, 15];
- this.faceList[10] = [12, 16, 17, 13];
- this.faceList[11] = [17, 16, 19, 18];
- this.faceList[12] = [12, 15, 19, 16];
- this.faceList[13] = [6, 0, 5, 11];
- };
- LapJoint.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var p2d;
- g.clear();
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- switch (nface) {
- case 1:
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- break;
- default:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- }
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- };
- //***************************************************************************************************************
- LapJoint.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- var mat = matMultiply(mx, my);
- this.initJoint();
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], mat);
- }
- if (rx >= 0) {
- if (ry > 90) {
- this.dlist = [1, 2, 8, 12, 10, 5, 0, 13, 9];
- } else if (ry >= 0) {
- this.dlist = [0, 1, 2, 3, 6, 10, 8, 7, 11, 10];
- } else if (ry >= -90) {
- this.dlist = [0, 1, 8, 2, 3, 4, 11, 6, 7];
- } else {
- this.dlist = [1, 2, 8, 12, 4, 5, 0, 13, 9];
- }
- } else if (rx < 0) {
- if (ry > 90) {
- this.dlist = [1, 2, 8, 13, 12, 10, 0, 6, 11];
- } else if (ry >= 0) {
- this.dlist = [0, 1, 2, 3, 5, 10, 9, 7, 8];
- } else if (ry >= -90) {
- this.dlist = [0, 1, 8, 2, 7, 3, 9, 5, 4];
- } else {
- this.dlist = [1, 2, 8, 12, 0, 11, 6, 4, 13];
- }
- }
- this.drawFaces(g);
- };
- LapJoint.prototype.explode = function (g, dx) {
- this.xShift = dx;
- this.draw(g);
- };
- return LapJoint;
- })(BaseJoint);
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- var MitreButt2 = (function (_super) {
- __extends(MitreButt2, _super);
- function MitreButt2(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = dx;
- this.vertexList = new Array(16);
- this.initJoint();
- this.initFaceList();
- }
- MitreButt2.prototype.initJoint = function () {
- var dy = -100;
- this.vertexList[0] = new Vertex(30 + this.xShift, dy, -30);
- this.vertexList[1] = new Vertex(30 + this.xShift, dy, 200);
- this.vertexList[2] = new Vertex(this.xShift, dy, 200);
- this.vertexList[3] = new Vertex(this.xShift, dy, 0);
- this.vertexList[4] = new Vertex(30 + this.xShift, -dy, -30);
- this.vertexList[5] = new Vertex(30 + this.xShift, -dy, 200);
- this.vertexList[6] = new Vertex(this.xShift, -dy, 200);
- this.vertexList[7] = new Vertex(this.xShift, -dy, 0);
- this.vertexList[8] = new Vertex(30 - this.xShift, dy, -30);
- this.vertexList[9] = new Vertex(-this.xShift, dy, 0);
- this.vertexList[10] = new Vertex(-200 - this.xShift, dy, 0);
- this.vertexList[11] = new Vertex(-200 - this.xShift, dy, -30);
- this.vertexList[12] = new Vertex(30 - this.xShift, -dy, -30);
- this.vertexList[13] = new Vertex(-this.xShift, -dy, 0);
- this.vertexList[14] = new Vertex(-200 - this.xShift, -dy, 0);
- this.vertexList[15] = new Vertex(-200 - this.xShift, -dy, -30);
- };
- MitreButt2.prototype.initFaceList = function () {
- this.faceList = new Array(12);
- this.faceList[0] = [0, 4, 5, 1];
- this.faceList[1] = [1, 5, 6, 2];
- this.faceList[2] = [3, 2, 6, 7];
- this.faceList[3] = [7, 4, 0, 3];
- this.faceList[4] = [0, 1, 2, 3];
- this.faceList[5] = [4, 7, 6, 5];
- this.faceList[6] = [11, 15, 12, 8];
- this.faceList[7] = [12, 13, 9, 8];
- this.faceList[8] = [10, 9, 13, 14];
- this.faceList[9] = [11, 10, 14, 15];
- this.faceList[10] = [11, 8, 9, 10];
- this.faceList[11] = [15, 14, 13, 12];
- };
- MitreButt2.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var p2d;
- g.clear();
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- switch (nface) {
- case 1:
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- break;
- default:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- }
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- };
- //***************************************************************************************************************
- MitreButt2.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- var mat = matMultiply(mx, my);
- this.initJoint();
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], mat);
- }
- if (rx >= 0) {
- if (ry > 90) {
- this.dlist = [7, 3, 2, 4, 1, 8, 9, 10];
- } else if (ry >= 0) {
- this.dlist = [2, 3, 7, 5, 5, 0, 6, 9, 11];
- } else if (ry >= -90) {
- this.dlist = [2, 7, 3, 11, 5, 6, 0];
- } else {
- this.dlist = [3, 7, 8, 10, 2, 4, 1, 0];
- }
- } else if (rx < 0) {
- if (ry > 90) {
- this.dlist = [3, 7, 1, 11, 8, 2, 5, 9];
- } else if (ry >= 0) {
- this.dlist = [2, 3, 7, 5, 4, 0, 6, 9, 10];
- } else if (ry >= -90) {
- this.dlist = [2, 7, 3, 10, 4, 6, 0];
- } else {
- this.dlist = [7, 3, 8, 11, 2, 5, 1, 0];
- }
- }
- this.drawFaces(g);
- };
- MitreButt2.prototype.explode = function (g, dx) {
- this.xShift = dx;
- this.draw(g);
- };
- return MitreButt2;
- })(BaseJoint);
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- var SplinedMitre = (function (_super) {
- __extends(SplinedMitre, _super);
- function SplinedMitre(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = dx;
- this.vertexList = new Array(104);
- this.initJoint();
- this.initFaceList();
- }
- SplinedMitre.prototype.initJoint = function () {
- var dz;
- var dy;
- var ds;
- //
- if (this.xShift > 75) {
- //open joint, but leave splines out
- dz = (this.xShift - 75) * 2.5;
- ds = 60;
- dy = 20;
- } else {
- //shut joint and move splines in
- dz = 0;
- ds = 60 * this.xShift / 75;
- dy = ds / 3;
- }
- var dt = 4;
- this.vertexList[0] = new Vertex(0, -100, dz);
- this.vertexList[1] = new Vertex(30, -100, -30 + dz);
- this.vertexList[2] = new Vertex(-200 - dz, -100, -30);
- this.vertexList[3] = new Vertex(15, -65, dz - 15);
- this.vertexList[4] = new Vertex(30, -75, -30 + dz);
- this.vertexList[5] = new Vertex(30, -65, dz);
- this.vertexList[6] = new Vertex(15, -65 + dt, dz - 15);
- this.vertexList[7] = new Vertex(30, -75 + dt, -30 + dz);
- this.vertexList[8] = new Vertex(30, -65 + dt, dz);
- this.vertexList[9] = new Vertex(15, -35, dz - 15);
- this.vertexList[10] = new Vertex(30, -25, -30 + dz);
- this.vertexList[11] = new Vertex(30, -35, dz);
- this.vertexList[12] = new Vertex(15, -35 + dt, dz - 15);
- this.vertexList[13] = new Vertex(30, -25 + dt, -30 + dz);
- this.vertexList[14] = new Vertex(30, -35 + dt, dz);
- this.vertexList[15] = new Vertex(15, 35 - dt, dz - 15);
- this.vertexList[16] = new Vertex(30, 25 - dt, -30 + dz);
- this.vertexList[17] = new Vertex(30, 35 - dt, dz);
- this.vertexList[18] = new Vertex(15, 35, dz - 15);
- this.vertexList[19] = new Vertex(30, 25, -30 + dz);
- this.vertexList[20] = new Vertex(30, 35, dz);
- this.vertexList[21] = new Vertex(15, 65 - dt, dz - 15);
- this.vertexList[22] = new Vertex(30, 75 - dt, -30 + dz);
- this.vertexList[23] = new Vertex(30, 65 - dt, dz);
- this.vertexList[24] = new Vertex(15, 65, dz - 15);
- this.vertexList[25] = new Vertex(30, 75, -30 + dz);
- this.vertexList[26] = new Vertex(30, 65, dz);
- this.vertexList[27] = new Vertex(0, 100, dz);
- this.vertexList[28] = new Vertex(30, 100, -30 + dz);
- this.vertexList[29] = new Vertex(-200 - dz, -100, 0);
- this.vertexList[30] = new Vertex(0, -100, 200 + dz);
- this.vertexList[31] = new Vertex(30, -100, 200 + dz);
- this.vertexList[32] = new Vertex(30, 100, 200 + dz);
- this.vertexList[33] = new Vertex(0, 100, 200 + dz);
- //spline 1 ->top - slides out and up
- this.vertexList[34] = new Vertex(ds, -65 - dy, -30);
- this.vertexList[35] = new Vertex(30 + ds, -75 - dy, -30);
- this.vertexList[36] = new Vertex(30 + ds, -65 - dy, 0);
- this.vertexList[37] = new Vertex(ds, -65 + dt - dy, -30);
- this.vertexList[38] = new Vertex(30 + ds, -75 + dt - dy, -30);
- this.vertexList[39] = new Vertex(30 + ds, -65 + dt - dy, 0);
- //spline 2 - slides out and down ->positive y shift
- this.vertexList[40] = new Vertex(0, -35 + dy, -30 - ds);
- this.vertexList[41] = new Vertex(30, -25 + dy, -30 - ds);
- this.vertexList[42] = new Vertex(30, -35 + dy, -ds);
- this.vertexList[43] = new Vertex(0, -35 + dt + dy, -30 - ds);
- this.vertexList[44] = new Vertex(30, -25 + dt + dy, -30 - ds);
- this.vertexList[45] = new Vertex(30, -35 + dt + dy, -ds);
- //spline 3 - slides out and up -> negative y shift
- this.vertexList[46] = new Vertex(ds, 35 - dt - dy, -30);
- this.vertexList[47] = new Vertex(30 + ds, 25 - dt - dy, -30);
- this.vertexList[48] = new Vertex(30 + ds, 35 - dt - dy, 0);
- this.vertexList[49] = new Vertex(ds, 35 - dy, -30);
- this.vertexList[50] = new Vertex(30 + ds, 25 - dy, -30);
- this.vertexList[51] = new Vertex(30 + ds, 35 - dy, 0);
- //spline 4 ->bottom - slides out and down ->positive y shift
- this.vertexList[52] = new Vertex(0, 65 - dt + dy, -30 - ds);
- this.vertexList[53] = new Vertex(30, 75 - dt + dy, -30 - ds);
- this.vertexList[54] = new Vertex(30, 65 - dt + dy, -ds);
- this.vertexList[55] = new Vertex(0, 65 + dy, -30 - ds);
- this.vertexList[56] = new Vertex(30, 75 + dy, -30 - ds);
- this.vertexList[57] = new Vertex(30, 65 + dy, -ds);
- //left hand side - shifted to -x
- this.vertexList[58] = new Vertex(-200 - dz, 100, -30);
- this.vertexList[59] = new Vertex(30 - dz, -100, -30);
- this.vertexList[60] = new Vertex(-dz, -100, 0);
- this.vertexList[61] = new Vertex(-dz, -65, -30);
- this.vertexList[62] = new Vertex(30 - dz, -75, -30);
- this.vertexList[63] = new Vertex(15 - dz, -65, -15);
- this.vertexList[64] = new Vertex(-dz, -65 + dt, -30);
- this.vertexList[65] = new Vertex(30 - dz, -75 + dt, -30);
- this.vertexList[66] = new Vertex(15 - dz, -65 + dt, -15);
- this.vertexList[67] = new Vertex(-dz, -35, -30);
- this.vertexList[68] = new Vertex(30 - dz, -25, -30);
- this.vertexList[69] = new Vertex(15 - dz, -35, -15);
- this.vertexList[70] = new Vertex(-dz, -35 + dt, -30);
- this.vertexList[71] = new Vertex(30 - dz, -25 + dt, -30);
- this.vertexList[72] = new Vertex(15 - dz, -35 + dt, -15);
- this.vertexList[73] = new Vertex(-dz, 35 - dt, -30);
- this.vertexList[74] = new Vertex(30 - dz, 25 - dt, -30);
- this.vertexList[75] = new Vertex(15 - dz, 35 - dt, -15);
- this.vertexList[76] = new Vertex(-dz, 35, -30);
- this.vertexList[77] = new Vertex(30 - dz, 25, -30);
- this.vertexList[78] = new Vertex(15 - dz, 35, -15);
- this.vertexList[79] = new Vertex(-dz, 65 - dt, -30);
- this.vertexList[80] = new Vertex(30 - dz, 75 - dt, -30);
- this.vertexList[81] = new Vertex(15 - dz, 65 - dt, -15);
- this.vertexList[82] = new Vertex(-dz, 65, -30);
- this.vertexList[83] = new Vertex(30 - dz, 75, -30);
- this.vertexList[84] = new Vertex(15 - dz, 65, -15);
- this.vertexList[85] = new Vertex(-200 - dz, 100, 0);
- this.vertexList[86] = new Vertex(30 - dz, 100, -30);
- this.vertexList[87] = new Vertex(-dz, 100, 0);
- //extra point to reshape splines when they enter slots
- if (ds >= 30) {
- //top spline shift -> +x,-y
- this.vertexList[88] = new Vertex(ds, -65 - dy, -30);
- this.vertexList[89] = new Vertex(ds + 15, -65 - dy, -15);
- this.vertexList[90] = new Vertex(ds, -65 - dy + dt, -30);
- this.vertexList[91] = new Vertex(ds + 15, -65 - dy + dt, -15);
- //spline2 shift -> -z,+y
- this.vertexList[92] = new Vertex(30, -35 + dy, -ds);
- this.vertexList[93] = new Vertex(15, -35 + dy, -15 - ds);
- this.vertexList[94] = new Vertex(30, -35 + dt + dy, -ds);
- this.vertexList[95] = new Vertex(15, -35 + dy + dt, -15 - ds);
- //spline 3 shift -> +x,-y
- this.vertexList[96] = new Vertex(ds, 35 - dt - dy, -30);
- this.vertexList[97] = new Vertex(ds + 15, 35 - dt - dy, -15);
- this.vertexList[98] = new Vertex(ds, 35 - dy, -30);
- this.vertexList[99] = new Vertex(ds + 15, 35 - dy, -15);
- //spline 4 shift -> -z,+y
- this.vertexList[100] = new Vertex(30, 65 - dt + dy, -ds);
- this.vertexList[101] = new Vertex(15, 65 + dy - dt, -15 - ds);
- this.vertexList[102] = new Vertex(30, 65 + dy, -ds);
- this.vertexList[103] = new Vertex(15, 65 + dy, -15 - ds);
- } else {
- //spline 1 shift -> +x,-y
- this.vertexList[88] = new Vertex(30, -75, -30);
- this.vertexList[89] = new Vertex(30, -65 - dy, -ds);
- this.vertexList[90] = new Vertex(30, -75 + dt, -30);
- this.vertexList[91] = new Vertex(30, -65 - dy + dt, -ds);
- //spline2 shift -> -z,+y
- this.vertexList[92] = new Vertex(30, -25, -30);
- this.vertexList[93] = new Vertex(ds, -35 + dy, -30);
- this.vertexList[94] = new Vertex(30, -25 + dt, -30);
- this.vertexList[95] = new Vertex(ds, -35 + dt + dy, -30);
- //spline 3 shift -> +x,-y
- this.vertexList[96] = new Vertex(30, 25 - dt, -30);
- this.vertexList[97] = new Vertex(30, 35 - dt - dy, -ds);
- this.vertexList[98] = new Vertex(30, 25, -30);
- this.vertexList[99] = new Vertex(30, 35 - dy, -ds);
- //spline 4 shift -> -z,+y
- this.vertexList[100] = new Vertex(30, 75 - dt, -30);
- this.vertexList[101] = new Vertex(ds, 65 - dt + dy, -30);
- this.vertexList[102] = new Vertex(30, 75, -30);
- this.vertexList[103] = new Vertex(ds, 65 + dy, -30);
- }
- };
- SplinedMitre.prototype.initFaceList = function () {
- this.faceList = new Array(56);
- this.faceList[0] = [3, 6, 8, 5];
- this.faceList[1] = [61, 64, 66, 63];
- this.faceList[2] = [9, 12, 14, 11];
- this.faceList[3] = [67, 70, 72, 69];
- this.faceList[4] = [15, 18, 20, 17];
- this.faceList[5] = [73, 76, 78, 75];
- this.faceList[6] = [21, 24, 26, 23];
- this.faceList[7] = [79, 82, 84, 81];
- this.faceList[8] = [4, 3, 5];
- this.faceList[9] = [61, 63, 62];
- this.faceList[10] = [6, 7, 8];
- this.faceList[11] = [64, 65, 66];
- this.faceList[12] = [9, 11, 10];
- this.faceList[13] = [67, 69, 68];
- this.faceList[14] = [12, 13, 14];
- this.faceList[15] = [70, 71, 72];
- this.faceList[16] = [15, 17, 16];
- this.faceList[17] = [73, 75, 74];
- this.faceList[18] = [18, 19, 20];
- this.faceList[19] = [76, 77, 78];
- this.faceList[20] = [21, 23, 22];
- this.faceList[21] = [79, 81, 80];
- this.faceList[22] = [24, 25, 26];
- this.faceList[23] = [82, 83, 84];
- this.faceList[24] = [34, 37, 38, 35];
- this.faceList[25] = [35, 38, 39, 36];
- this.faceList[26] = [88, 35, 36, 89];
- this.faceList[27] = [38, 90, 91, 39];
- this.faceList[28] = [34, 36, 39, 37];
- this.faceList[29] = [40, 43, 44, 41];
- this.faceList[30] = [41, 44, 45, 42];
- this.faceList[31] = [40, 41, 92, 93];
- this.faceList[32] = [44, 43, 95, 94];
- this.faceList[33] = [95, 43, 40, 93];
- this.faceList[34] = [46, 49, 50, 47];
- this.faceList[35] = [47, 50, 51, 48];
- this.faceList[36] = [96, 47, 48, 97];
- this.faceList[37] = [50, 98, 99, 51];
- this.faceList[38] = [46, 48, 51, 49];
- this.faceList[39] = [52, 55, 56, 53];
- this.faceList[40] = [53, 56, 57, 54];
- this.faceList[41] = [52, 53, 100, 101];
- this.faceList[42] = [56, 55, 103, 102];
- this.faceList[43] = [103, 55, 52, 101];
- this.faceList[44] = [2, 29, 85, 58];
- this.faceList[45] = [60, 59, 62, 63, 66, 65, 68, 69, 72, 71, 74, 75, 78, 77, 80, 81, 84, 83, 86, 87];
- this.faceList[46] = [0, 27, 28, 25, 24, 21, 22, 19, 18, 15, 16, 13, 12, 9, 10, 7, 6, 3, 4, 1];
- this.faceList[47] = [31, 1, 4, 5, 8, 7, 10, 11, 14, 13, 16, 17, 20, 19, 22, 23, 26, 25, 28, 32];
- this.faceList[48] = [2, 58, 86, 83, 82, 79, 80, 77, 76, 73, 74, 71, 70, 67, 68, 65, 64, 61, 62, 59];
- this.faceList[49] = [0, 1, 31, 30];
- this.faceList[50] = [2, 59, 60, 29];
- this.faceList[51] = [0, 30, 33, 27];
- this.faceList[52] = [27, 33, 32, 28];
- this.faceList[53] = [93, 42, 45, 95];
- this.faceList[54] = [101, 54, 57, 103];
- this.faceList[55] = [58, 85, 87, 86];
- };
- SplinedMitre.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var p2d;
- g.clear();
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- //switch(nface){
- //case 1:
- //color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- //break;
- //default:
- //color = getFaceColor(p1, p2, p0, Wood.clfFace);
- //}
- if (nface < 24) {
- color = getFaceColor(p1, p2, p0, Wood.clfHole);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- } else if (nface < 44) {
- color = getFaceColor(p1, p2, p0, Wood.clfPanel);
- if ((nface == 33) || (nface == 34) || (nface == 43)) {
- g.f(color).ss(1, 2).s(color);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp().ef();
- g.s(clDowelEdge).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).es();
- } else {
- g.f(color).s(clDowelEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- } else if ((nface == 53) || (nface == 54)) {
- color = getFaceColor(p1, p2, p0, Wood.clfPanel);
- g.f(color).ss(1, 2).s(color);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp().ef();
- g.s(clDowelEdge).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).es();
- } else if ((nface == 44) || (nface == 45) || (nface == 46)) {
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- } else {
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- }
- };
- //***************************************************************************************************************
- SplinedMitre.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- var mat = matMultiply(mx, my);
- this.initJoint();
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], mat);
- }
- var flag = visible3DFace(this.vertexList[4], this.vertexList[1], this.vertexList[3]);
- if (this.xShift > 75) {
- //mitre joint open
- if ((rx >= 0) && flag) {
- if (ry <= 0) {
- this.dlist = [
- 51, 0, 2, 4, 6, 1, 3, 5, 7,
- 8, 10, 12, 14, 16, 18, 20, 22, 46, 47, 52,
- 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 45,
- 48, 55, 44,
- 24, 25, 26, 27, 28,
- 34, 35, 36, 37, 38,
- 29, 30, 31, 32, 33, 53,
- 39, 40, 41, 42, 43, 54];
- } else {
- this.dlist = [
- 51, 0, 2, 4, 6, 1, 3, 5, 7,
- 8, 10, 12, 14, 16, 18, 20, 22, 46, 47, 52,
- 24, 25, 26, 27, 28,
- 34, 35, 36, 37, 38,
- 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 45,
- 48, 55, 44,
- 29, 30, 31, 32, 33, 53,
- 39, 40, 41, 42, 43, 54];
- }
- } else if ((rx >= 0) && !flag) {
- this.dlist = [
- 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23,
- 45, 48, 55,
- 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
- 47, 52,
- 29, 30, 31, 32,
- 39, 40, 41, 42,
- 24, 25, 26, 27,
- 34, 35, 36, 37];
- } else if ((rx < 0) && flag) {
- if (ry <= 0) {
- this.dlist = [
- 51, 0, 2, 4, 6, 22, 20, 18, 16, 14, 12, 10, 8,
- 46, 45, 47, 49,
- 7, 5, 3, 1, 23, 21, 19, 17, 15, 13, 11, 9,
- 34, 35, 36, 37, 38,
- 24, 25, 26, 27, 28,
- 48, 50, 44,
- 39, 40, 41, 42, 43, 54, 29, 30, 31, 32, 33, 53];
- } else {
- this.dlist = [
- 34, 35, 36, 37, 38, 24, 25, 26, 27, 28,
- 51, 0, 2, 4, 6, 22, 20, 18, 16, 14, 12, 10, 8,
- 46, 45, 47, 49,
- 7, 5, 3, 1, 23, 21, 19, 17, 15, 13, 11, 9,
- 48, 50, 44,
- 39, 40, 41, 42, 43, 54, 29, 30, 31, 32, 33, 53];
- }
- } else if ((rx < 0) && !flag) {
- this.dlist = [
- 7, 5, 3, 1, 23, 21, 19, 17, 15, 13, 11, 9,
- 45, 48, 50,
- 51, 0, 2, 4, 6, 22, 20, 18, 16, 14, 12, 10, 8,
- 47, 49,
- 39, 40, 41, 42, 43,
- 34, 35, 36, 37, 38,
- 29, 30, 31, 32, 33,
- 24, 25, 26, 27, 28];
- }
- } else {
- //mitre joint together
- if ((rx >= 0) && (ry >= 0)) {
- this.dlist = [
- 26, 27,
- 36, 37,
- 51, 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 53, 54, 28, 38, 24, 34,
- 48, 55, 52,
- 29, 31, 32, 33,
- 39, 41, 42, 43, 44];
- } else if ((rx >= 0) && (ry < 0)) {
- this.dlist = [
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
- 48, 47,
- 24, 25, 26, 27,
- 29, 30, 31, 32,
- 34, 35, 36, 37,
- 39, 40, 41, 42, 55, 52];
- } else if ((rx < 0) && (ry >= 0)) {
- this.dlist = [
- 51, 6, 7, 4, 5, 3, 2, 1, 0,
- 22, 23, 20, 21, 18, 19, 16, 17,
- 14, 15, 12, 13, 10, 11, 8, 9,
- 53, 54,
- 47,
- 34, 35, 36, 37, 38,
- 24, 25, 26, 27, 28,
- 48, 33, 43,
- 39, 40, 41, 42,
- 29, 30, 31, 32, 44, 49, 50];
- } else {
- this.dlist = [
- 51, 6, 7, 4, 5, 3, 2, 1, 0,
- 22, 23, 20, 21, 18, 19, 16, 17,
- 14, 15, 12, 13, 10, 11, 8, 9,
- 44, 47, 48,
- 39, 40, 41, 42, 43,
- 29, 30, 31, 32, 33,
- 34, 35, 36, 37, 38,
- 28, 24, 26, 25, 27,
- 50, 49];
- }
- }
- this.drawFaces(g);
- };
- SplinedMitre.prototype.explode = function (g, dx) {
- this.xShift = dx;
- this.draw(g);
- };
- return SplinedMitre;
- })(BaseJoint);
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- var SquareEndButt2 = (function (_super) {
- __extends(SquareEndButt2, _super);
- function SquareEndButt2(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = dx;
- this.vertexList = new Array(16);
- this.initJoint();
- this.initFaceList();
- }
- SquareEndButt2.prototype.initJoint = function () {
- //
- var y = 100;
- var x = this.xShift / 2;
- var z = 15;
- //left cuboid
- this.vertexList[0] = new Vertex(-x - 200, -y, z);
- this.vertexList[1] = new Vertex(-x, -y, z);
- this.vertexList[2] = new Vertex(-x, -y, -z);
- this.vertexList[3] = new Vertex(-x - 200, -y, -z);
- this.vertexList[4] = new Vertex(-x - 200, y, z);
- this.vertexList[5] = new Vertex(-x, y, z);
- this.vertexList[6] = new Vertex(-x, y, -z);
- this.vertexList[7] = new Vertex(-x - 200, y, -z);
- //right cuboid
- this.vertexList[8] = new Vertex(x, -y, 200);
- this.vertexList[9] = new Vertex(x + 30, -y, 200);
- this.vertexList[10] = new Vertex(x + 30, -y, -z);
- this.vertexList[11] = new Vertex(x, -y, -z);
- this.vertexList[12] = new Vertex(x, y, 200);
- this.vertexList[13] = new Vertex(x + 30, y, 200);
- this.vertexList[14] = new Vertex(x + 30, y, -z);
- this.vertexList[15] = new Vertex(x, y, -z);
- };
- SquareEndButt2.prototype.initFaceList = function () {
- this.faceList = new Array(12);
- //left
- this.faceList[0] = [0, 3, 2, 1];
- this.faceList[1] = [4, 5, 6, 7];
- this.faceList[2] = [2, 3, 7, 6];
- this.faceList[3] = [0, 1, 5, 4];
- this.faceList[4] = [5, 1, 2, 6];
- this.faceList[5] = [0, 4, 7, 3];
- //right
- this.faceList[6] = [8, 11, 10, 9];
- this.faceList[7] = [12, 13, 14, 15];
- this.faceList[8] = [9, 10, 14, 13];
- this.faceList[9] = [8, 12, 15, 11];
- this.faceList[10] = [10, 11, 15, 14];
- this.faceList[11] = [8, 9, 13, 12];
- };
- SquareEndButt2.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var p2d;
- g.clear();
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- switch (nface) {
- case 4:
- case 5:
- case 10:
- case 11:
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- break;
- default:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- }
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- };
- //***************************************************************************************************************
- SquareEndButt2.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- var mat = matMultiply(mx, my);
- this.initJoint();
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], mat);
- }
- if (ry >= 0) {
- this.dlist = [6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5];
- } else {
- this.dlist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
- }
- this.drawFaces(g);
- };
- SquareEndButt2.prototype.explode = function (g, dx) {
- this.xShift = dx;
- this.draw(g);
- };
- return SquareEndButt2;
- })(BaseJoint);
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- /**********************************************************************************************************/
- /*Return xyx coordinates of a horizontal cylinder made up off 20 faces.
- nLength is the length and radius is the radius.
- The first and last entries in the array are identical, since it makes the drawing code easier
- N.B. nLength = length of dowel /2
- */
- function getCylinder(x0, y0, z0, nLength, radius) {
- var j, a;
- var da = Math.PI / 10;
- var res = new Array(42);
- for (j = 0; j <= 20; j++) {
- a = j * da;
- res[j] = new Vertex(x0 - nLength, y0 + radius * Math.sin(a), z0 + radius * Math.cos(a));
- res[j + 21] = new Vertex(x0 + nLength, res[j].y, res[j].z);
- }
- return res;
- }
- /*****************************************************************************************************
- * Return 3D points to define a cylindrical hole from x0 to x0 - nLength
- ******************************************************************************************************/
- function getLeftHole(x0, y0, z0, nLength, radius) {
- var j, a;
- var da = Math.PI / 10;
- var res = new Array(42);
- for (j = 0; j <= 20; j++) {
- a = j * da;
- res[j] = new Vertex(x0, y0 + radius * Math.sin(a), z0 + radius * Math.cos(a));
- res[j + 21] = new Vertex(x0 - nLength, res[j].y, res[j].z);
- }
- return res;
- }
- /*****************************************************************************************************
- * Return 3D points to define a cylindrical hole from x0 to x0 + nLength
- ******************************************************************************************************/
- function getRightHole(x0, y0, z0, nLength, radius) {
- var j, a;
- var da = Math.PI / 10;
- var res = new Array(42);
- for (j = 0; j <= 20; j++) {
- a = j * da;
- res[j] = new Vertex(x0, y0 - radius * Math.sin(a), z0 + radius * Math.cos(a));
- res[j + 21] = new Vertex(x0 + nLength, res[j].y, res[j].z);
- }
- return res;
- }
- /*********************************************************************************************************
- * Draw a cylinder centered at (x0, y0, z0)
- */
- function drawCylinder(g, x0, y0, z0, nLength, radius, mat, xOff, yOff) {
- var c = [];
- var j;
- var a = new Array(4);
- var p0;
- var p1;
- var p2;
- var p3;
- var color;
- var ap;
- c = getCylinder(x0, y0, z0, nLength, radius);
- for (j = 0; j < c.length; j++) {
- c[j] = applyMatrix(c[j], mat);
- }
- for (j = 0; j <= 19; j++) {
- p0 = c[j];
- p1 = c[j + 21];
- p2 = c[j + 22];
- p3 = c[j + 1];
- if (visible3DFace(p1, p2, p0)) {
- a[0] = get2dPoint(p0, xOff, yOff);
- a[1] = get2dPoint(p1, xOff, yOff);
- a[2] = get2dPoint(p2, xOff, yOff);
- a[3] = get2dPoint(p3, xOff, yOff);
- color = getFaceColor(p1, p2, p0, Wood.clfDowel);
- g.f(color).s(color).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp();
- //g.s(clEdge).mt(a[1].x, a[1].y).lt(a[2].x, a[2].y).es();
- }
- }
- //draw end faces
- p0 = c[0];
- p1 = c[1];
- p2 = c[2];
- if (visible3DFace(p1, p2, p0)) {
- color = getFaceColor(p1, p2, p0, Wood.clfDowel);
- ap = get2dPoint(c[0], xOff, yOff);
- g.s(clDowelEdge).mt(ap.x, ap.y);
- for (j = 1; j <= 20; j++) {
- ap = get2dPoint(c[j], xOff, yOff);
- g.lt(ap.x, ap.y);
- }
- }
- //
- p0 = c[23];
- p1 = c[22];
- p2 = c[21];
- if (visible3DFace(p1, p2, p0)) {
- color = getFaceColor(p1, p2, p0, Wood.clfDowel);
- ap = get2dPoint(c[21], xOff, yOff);
- g.s(clDowelEdge).mt(ap.x, ap.y);
- for (j = 1; j <= 20; j++) {
- ap = get2dPoint(c[j + 21], xOff, yOff);
- g.lt(ap.x, ap.y);
- }
- }
- }
- /*********************************************************************************************************
- * Draw a dowel hole for the left cuboid
- *******************************************************************************************************/
- function drawLeftHole(g, x0, y0, z0, nLength, radius, mat, xOff, yOff) {
- var c = [];
- var j;
- var a = new Array(4);
- var p0;
- var p1;
- var p2;
- var p3;
- var color;
- var ap;
- var res = new Array(21);
- c = getLeftHole(x0, y0, z0, nLength, radius);
- for (j = 0; j < c.length; j++) {
- c[j] = applyMatrix(c[j], mat);
- }
- for (j = 0; j <= 19; j++) {
- p0 = c[j];
- p1 = c[j + 21];
- p2 = c[j + 22];
- p3 = c[j + 1];
- if (visible3DFace(p1, p2, p0)) {
- a[0] = get2dPoint(p0, xOff, yOff);
- a[1] = get2dPoint(p1, xOff, yOff);
- a[2] = get2dPoint(p2, xOff, yOff);
- a[3] = get2dPoint(p3, xOff, yOff);
- color = getFaceColor(p1, p2, p0, Wood.clfDowelHole);
- g.f(color).s(color).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp();
- }
- }
- p0 = c[23];
- p1 = c[22];
- p2 = c[21];
- if (visible3DFace(p1, p2, p0)) {
- color = getFaceColor(p1, p2, p0, Wood.clfDowel);
- ap = get2dPoint(c[21], xOff, yOff);
- g.s(clEdge).mt(ap.x, ap.y);
- for (j = 1; j <= 20; j++) {
- ap = get2dPoint(c[j + 21], xOff, yOff);
- g.lt(ap.x, ap.y);
- }
- }
- for (j = 0; j <= 20; j++) {
- res[j] = get2dPoint(c[j], xOff, yOff);
- }
- return res;
- }
- /*********************************************************************************************************
- * Draw a dowel hole for the right cuboid
- *******************************************************************************************************/
- function drawRightHole(g, x0, y0, z0, nLength, radius, mat, xOff, yOff) {
- var c = [];
- var j;
- var a = new Array(4);
- var p0;
- var p1;
- var p2;
- var p3;
- var color;
- var ap;
- var res = new Array(21);
- c = getRightHole(x0, y0, z0, nLength, radius);
- for (j = 0; j < c.length; j++) {
- c[j] = applyMatrix(c[j], mat);
- }
- for (j = 0; j <= 19; j++) {
- p0 = c[j];
- p1 = c[j + 21];
- p2 = c[j + 22];
- p3 = c[j + 1];
- if (visible3DFace(p1, p2, p0)) {
- a[0] = get2dPoint(p0, xOff, yOff);
- a[1] = get2dPoint(p1, xOff, yOff);
- a[2] = get2dPoint(p2, xOff, yOff);
- a[3] = get2dPoint(p3, xOff, yOff);
- color = getFaceColor(p1, p2, p0, Wood.clfDowelHole);
- g.f(color).s(color).mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).cp();
- }
- }
- p0 = c[23];
- p1 = c[22];
- p2 = c[21];
- if (visible3DFace(p1, p2, p0)) {
- color = getFaceColor(p1, p2, p0, Wood.clfDowel);
- ap = get2dPoint(c[21], xOff, yOff);
- g.s(clEdge).mt(ap.x, ap.y);
- for (j = 1; j <= 20; j++) {
- ap = get2dPoint(c[j + 21], xOff, yOff);
- g.lt(ap.x, ap.y);
- }
- }
- for (j = 0; j <= 20; j++) {
- res[j] = get2dPoint(c[j], xOff, yOff);
- }
- return res;
- }
- ///<reference path='../../common/ts/easeljs.d.ts'/>
- ///<reference path='wood3d.ts'/>
- ///<reference path='dowel-utils.ts'/>
- var DowelButt = (function (_super) {
- __extends(DowelButt, _super);
- function DowelButt(dx) {
- _super.call(this);
- this.dlist = [];
- this.xShift = 0;
- this.xShift = 1.5 * dx;
- this.vertexList = new Array(16);
- this.initJoint();
- this.initFaceList();
- }
- DowelButt.prototype.initJoint = function () {
- var y = 100;
- var x = this.xShift / 2;
- var z = 15;
- //left cuboid
- this.vertexList[0] = new Vertex(-x - 200, -y, z);
- this.vertexList[1] = new Vertex(-x, -y, z);
- this.vertexList[2] = new Vertex(-x, -y, -z);
- this.vertexList[3] = new Vertex(-x - 200, -y, -z);
- this.vertexList[4] = new Vertex(-x - 200, y, z);
- this.vertexList[5] = new Vertex(-x, y, z);
- this.vertexList[6] = new Vertex(-x, y, -z);
- this.vertexList[7] = new Vertex(-x - 200, y, -z);
- //right cuboid
- this.vertexList[8] = new Vertex(x, -y, 200);
- this.vertexList[9] = new Vertex(x + 30, -y, 200);
- this.vertexList[10] = new Vertex(x + 30, -y, -z);
- this.vertexList[11] = new Vertex(x, -y, -z);
- this.vertexList[12] = new Vertex(x, y, 200);
- this.vertexList[13] = new Vertex(x + 30, y, 200);
- this.vertexList[14] = new Vertex(x + 30, y, -z);
- this.vertexList[15] = new Vertex(x, y, -z);
- };
- DowelButt.prototype.initFaceList = function () {
- this.faceList = new Array(12);
- //left
- this.faceList[0] = [0, 3, 2, 1];
- this.faceList[1] = [4, 5, 6, 7];
- this.faceList[2] = [2, 3, 7, 6];
- this.faceList[3] = [0, 1, 5, 4];
- this.faceList[4] = [5, 1, 2, 6];
- this.faceList[5] = [0, 4, 7, 3];
- //right
- this.faceList[6] = [8, 11, 10, 9];
- this.faceList[7] = [12, 13, 14, 15];
- this.faceList[8] = [9, 10, 14, 13];
- this.faceList[9] = [8, 12, 15, 11];
- this.faceList[10] = [10, 11, 15, 14];
- this.faceList[11] = [8, 9, 13, 12];
- };
- DowelButt.prototype.drawFaces = function (g) {
- var j, k, n;
- var p0;
- var p1;
- var p2;
- var p;
- var a = [];
- var nface;
- var face = [];
- var color;
- var p2d;
- var hp = [];
- var hp1 = [];
- var hp2 = [];
- var r = 8;
- for (j = 0; j < this.dlist.length; j++) {
- p0 = this.vertexList[this.faceList[this.dlist[j]][0]];
- p1 = this.vertexList[this.faceList[this.dlist[j]][1]];
- p2 = this.vertexList[this.faceList[this.dlist[j]][2]];
- if (visible3DFace(p0, p1, p2)) {
- nface = this.dlist[j];
- face = this.faceList[nface];
- a = new Array(face.length);
- for (k = 0; k < face.length; k++) {
- p = this.vertexList[face[k]];
- a[k] = get2dPoint(p, this.xOffset, this.yOffset);
- }
- switch (nface) {
- case 4:
- case 5:
- case 10:
- case 11:
- color = getFaceColor(p1, p2, p0, Wood.clfEndGrain);
- break;
- default:
- color = getFaceColor(p1, p2, p0, Wood.clfFace);
- }
- if ((nface == 4) && (this.xShift > 40)) {
- hp = drawLeftHole(g, -this.xShift / 2, -80, 0, 20, r, this.mat, this.xOffset, this.yOffset);
- hp1 = drawLeftHole(g, -this.xShift / 2, 0, 0, 20, r, this.mat, this.xOffset, this.yOffset);
- hp2 = drawLeftHole(g, -this.xShift / 2, 80, 0, 20, r, this.mat, this.xOffset, this.yOffset);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).lt(a[0].x, a[0].y);
- g.mt(hp[0].x, hp[0].y);
- for (n = 0; n <= 20; n++) {
- g.lt(hp[n].x, hp[n].y);
- }
- g.mt(hp1[0].x, hp1[0].y);
- for (n = 0; n <= 20; n++) {
- g.lt(hp1[n].x, hp1[n].y);
- }
- g.mt(hp2[0].x, hp2[0].y);
- for (n = 0; n <= 20; n++) {
- g.lt(hp2[n].x, hp2[n].y);
- }
- g.cp().es().ef();
- } else if ((nface == 9) && (this.xShift > 40)) {
- hp = drawRightHole(g, this.xShift / 2, -80, 0, 20, r, this.mat, this.xOffset, this.yOffset);
- hp1 = drawRightHole(g, this.xShift / 2, 0, 0, 20, r, this.mat, this.xOffset, this.yOffset);
- hp2 = drawRightHole(g, this.xShift / 2, 80, 0, 20, r, this.mat, this.xOffset, this.yOffset);
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y).lt(a[1].x, a[1].y).lt(a[2].x, a[2].y).lt(a[3].x, a[3].y).lt(a[0].x, a[0].y);
- g.mt(hp[0].x, hp[0].y);
- for (n = 0; n <= 20; n++) {
- g.lt(hp[n].x, hp[n].y);
- }
- g.mt(hp1[0].x, hp1[0].y);
- for (n = 0; n <= 20; n++) {
- g.lt(hp1[n].x, hp1[n].y);
- }
- g.mt(hp2[0].x, hp2[0].y);
- for (n = 0; n <= 20; n++) {
- g.lt(hp2[n].x, hp2[n].y);
- }
- g.cp().es().ef();
- } else {
- g.f(color).s(clEdge);
- g.mt(a[0].x, a[0].y);
- for (n = 1; n < face.length; n++) {
- g.lt(a[n].x, a[n].y);
- }
- g.cp().es().ef();
- }
- }
- }
- };
- //***************************************************************************************************************
- DowelButt.prototype.draw = function (g) {
- var j;
- var mx = new RotationMatrix(rx, 0);
- var my = new RotationMatrix(ry, 1);
- this.mat = matMultiply(mx, my);
- this.initJoint();
- var r = 8;
- var dx;
- //dx = 20;
- if (this.xShift < 40)
- dx = this.xShift / 2;
- else
- dx = 20;
- for (j = 0; j < this.vertexList.length; j++) {
- this.vertexList[j] = applyMatrix(this.vertexList[j], this.mat);
- }
- g.clear();
- if (rx >= 0) {
- if (ry > 90) {
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- } else if (ry >= 0) {
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- } else if (ry >= -90) {
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- } else {
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- }
- } else if (rx < 0) {
- if (ry > 90) {
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- } else if (ry >= 0) {
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- } else if (ry >= -90) {
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- } else {
- this.dlist = [4, 0, 1, 2, 3, 5];
- this.drawFaces(g);
- drawCylinder(g, 0, -80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 0, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- drawCylinder(g, 0, 80, 0, dx, r, this.mat, this.xOffset, this.yOffset);
- this.dlist = [9, 6, 7, 8, 10, 11];
- this.drawFaces(g);
- }
- }
- };
- DowelButt.prototype.explode = function (g, dx) {
- this.xShift = 1.5 * dx;
- this.draw(g);
- };
- return DowelButt;
- })(BaseJoint);
- ///<reference path='../../../common/ts/easeljs.d.ts'/>
- ///<reference path='../../../common/ts/slider-cb.ts'/>
- ///<reference path='../../../common/ts/pjradiobutton.ts'/>
- ///<reference path='../../wood3d/wood3d.ts'/>
- ///<reference path='../../wood3d/thumbnail.ts'/>
- ///<reference path='../../wood3d/butt-rub.ts'/>
- ///<reference path='../../wood3d/through-dovetail.ts'/>
- ///<reference path='../../wood3d/lap-joint.ts'/>
- ///<reference path='../../wood3d/mitre-butt2.ts'/>
- ///<reference path='../../wood3d/splined-mitre.ts'/>
- ///<reference path='../../wood3d/sqend-butt2.ts'/>
- ///<reference path='../../wood3d/dowel-butt.ts'/>
- var dpr = 1;
- var scale = 1;
- var baseWidth = 620;
- var baseHeight = 400;
- var stage;
- var drag = false;
- var mx = 0;
- var my = 0;
- var rx = 0;
- var ry = 0;
- var view = new createjs.Shape();
- var joint;
- var thumbs = new Array(7);
- var explodeSlider = new SliderCB(300, 30, 0);
- var info = new createjs.Text('', 'bold 14px Arial', '#ffffff');
- var ryMax = 180;
- var canUpdate = false;
- function init() {
- if (window.devicePixelRatio) {
- dpr = window.devicePixelRatio;
- }
- scale = dpr;
- // get a reference to the canvas we'll be working with:
- var canvas = document.getElementById('canvas');
- // create a stage object to work with the canvas. This is the top level node in the display list:
- stage = new createjs.Stage(canvas);
- //set the canvas size
- var ua = navigator.userAgent.toLowerCase();
- var isAndroid = ua.indexOf("android") > -1;
- if (isAndroid) {
- doFixedResize();
- } else {
- doScaleResize();
- window.addEventListener("orientationchange", function () {
- doScaleResize();
- }, false);
- }
- // enable touch interactions if supported on the current device:
- createjs.Touch.enable(stage);
- //disable mouseover
- stage.enableMouseOver(0);
- var mt = new createjs.Shape();
- mt.graphics.f('#003D84').dr(-200, -180, 400, 360);
- mt.setTransform(200, 180);
- stage.addChild(mt);
- mt.addEventListener('mousedown', doMouse);
- mt.addEventListener('pressmove', doMouse);
- mt.addEventListener('pressup', doMouse);
- view.setTransform(200, 180);
- stage.addChild(view);
- var msk = new createjs.Shape();
- msk.graphics.f('#000000').dr(0, 0, 400, 360);
- view.mask = msk;
- info.setTransform(5, 5);
- stage.addChild(info);
- initGroupImage();
- initThumbnails();
- initControls();
- showThumbnails(0x1);
- doThumbnailClick(Wood.jtButtRub, 0x1);
- createjs.Ticker.timingMode = createjs.Ticker.RAF;
- createjs.Ticker.addEventListener("tick", doTick);
- }
- //**************************************************************************************************************
- // ToDo add default rx and ry values here
- //**************************************************************************************************************
- function initJoint(jointID) {
- switch (jointID) {
- case Wood.jtDowelButt:
- rx = -20;
- ry = 20;
- joint = new DowelButt(100);
- joint.xOffset = 30;
- joint.yOffset = 14;
- break;
- case Wood.jtLap:
- rx = -25;
- ry = -19;
- joint = new LapJoint(100);
- joint.xOffset = 38;
- joint.yOffset = 14;
- break;
- case Wood.jtThroughDovetail:
- rx = -17;
- ry = -32;
- joint = new ThroughDovetail(100);
- joint.xOffset = 5;
- joint.yOffset = -20;
- break;
- case Wood.jtMitredButt2:
- rx = -23;
- ry = -19;
- joint = new MitreButt2(100);
- joint.xOffset = 40;
- joint.yOffset = 12;
- break;
- case Wood.jtSplinedMitre:
- rx = -16;
- ry = -20;
- joint = new SplinedMitre(100);
- joint.xOffset = 27;
- joint.yOffset = 2;
- break;
- case Wood.jtSquareEndButt2:
- rx = -16;
- ry = -25;
- joint = new SquareEndButt2(100);
- joint.xOffset = 13;
- joint.yOffset = 2;
- break;
- case Wood.jtButtRub:
- rx = -27;
- ry = 15;
- joint = new ButtRubJoint(100);
- joint.xOffset = -32;
- joint.yOffset = -7;
- break;
- }
- }
- //*****************************************************************************************************
- //Two sliders to zoom and explode the joint
- //*****************************************************************************************************
- function initControls() {
- explodeSlider.min = -100000;
- explodeSlider.max = 100000;
- explodeSlider.showValue = false;
- explodeSlider.setTransform(50, 365);
- explodeSlider.setValue(0);
- stage.addChild(explodeSlider);
- explodeSlider.addCallback(sliderChange);
- var slider = new SliderCB(300, 30, 1);
- slider.min = 0.50;
- slider.max = 1.00;
- slider.dp = 2;
- slider.showValue = false;
- slider.setTransform(405, 330, 1, 1, -90);
- slider.setValue(0.75);
- stage.addChild(slider);
- slider.addCallback(sliderChange);
- }
- //*****************************************************************************************************
- //Large group image with radio buttons
- //*****************************************************************************************************
- function initGroupImage() {
- var mc = new lib.BoxGroup();
- mc.setTransform(440, 4);
- stage.addChild(mc);
- }
- //*****************************************************************************************************
- //Joint thumbnails - these are all in wood-lib.js
- //*****************************************************************************************************
- function initThumbnails() {
- var holder = new createjs.Container();
- holder.setTransform(440, 160);
- stage.addChild(holder);
- var tn = new Thumbnail(new lib.Buttrub(), Wood.jtButtRub, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[0] = tn;
- tn = new Thumbnail(new lib.ThroughDovetail(), Wood.jtThroughDovetail, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[1] = tn;
- tn = new Thumbnail(new lib.LapJoint(), Wood.jtLap, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[2] = tn;
- tn = new Thumbnail(new lib.MitreButt2(), Wood.jtMitredButt2, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[3] = tn;
- tn = new Thumbnail(new lib.SplinedMitre(), Wood.jtSplinedMitre, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[4] = tn;
- tn = new Thumbnail(new lib.SqEndButt2(), Wood.jtSquareEndButt2, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[5] = tn;
- tn = new Thumbnail(new lib.DowelButt(), Wood.jtDowelButt, 0x1);
- holder.addChild(tn);
- tn.addCallback(doThumbnailClick);
- thumbs[6] = tn;
- }
- //*****************************************************************************************************
- //Input hs as 0x1, 0x10, 0x100 or 0x1000.
- //Each thumbnail has a hotspot value which is a binary 4 bit number, so we mask this hs to determine
- //if the joint thumbnail should be displayed
- //*****************************************************************************************************
- function showThumbnails(hs) {
- var j;
- var x = 0;
- var y = 0;
- var n;
- var count = 0;
- var tn;
- var firstTN = 0;
- for (j = 0; j < thumbs.length; j++) {
- tn = thumbs[j];
- n = tn.hotspot;
- if ((n & hs) == hs) {
- if (count == 0)
- firstTN = tn.jointID;
- if (count < 6) {
- x = 80 * (count % 2);
- y = 55 * Math.floor(count / 2);
- } else {
- x = 0;
- y = 165; // 60 * ((count - 6) % 3);
- }
- tn.setTransform(x, y);
- tn.visible = true;
- count++;
- } else {
- tn.visible = false;
- }
- }
- return firstTN;
- }
- //*****************************************************************************************************
- //Handle the rotation of the 3D display
- //*****************************************************************************************************
- function doMouse(e) {
- if (e.type == 'mousedown') {
- drag = true;
- mx = e.localX;
- my = e.localY;
- } else if (e.type == 'pressmove') {
- if (drag) {
- ry += (e.localX - mx);
- rx += (my - e.localY);
- if (rx < -90)
- rx = -90;
- else if (rx > 90)
- rx = 90;
- if (ry < -ryMax)
- ry = -ryMax;
- else if (ry > ryMax)
- ry = ryMax;
- mx = e.localX;
- my = e.localY;
- joint.draw(view.graphics);
- }
- } else if (e.type == 'pressup') {
- drag = false;
- }
- canUpdate = true;
- }
- //*****************************************************************************************************
- //Handle slider changes to zoom or explode the joint.
- //*****************************************************************************************************
- function sliderChange(tag, value) {
- if (tag == 0) {
- joint.explode(view.graphics, 100 - value);
- } else if (tag == 1) {
- zoom = value * eyePos;
- joint.draw(view.graphics);
- }
- canUpdate = true;
- }
- //*****************************************************************************************************
- //Callback function to handle a click on one of the thumbnails
- //*****************************************************************************************************
- function doThumbnailClick(jointID, hotspot) {
- info.text = getJointName(jointID);
- explodeSlider.setValue(0);
- initJoint(jointID);
- joint.draw(view.graphics);
- var j;
- for (j = 0; j < thumbs.length; j++) {
- thumbs[j].setSelected(thumbs[j].jointID == jointID);
- }
- if (jointID == Wood.jtSplinedMitre)
- ryMax = 90;
- else
- ryMax = 180;
- stage.update();
- $('#info').load(getInfoFilename(jointID));
- }
- function doTick(e) {
- if (canUpdate) {
- stage.update();
- canUpdate = false;
- }
- }
- //--------------------------------------------------------------------------------------------------------------
- //Initialize the animation
- //--------------------------------------------------------------------------------------------------------------
- window.onload = function () {
- init();
- stage.update();
- };
- //--------------------------------------------------------------------------------------------------------------
- //Resize the animation
- //--------------------------------------------------------------------------------------------------------------
- function doFixedResize() {
- var max = Math.min(screen.width, screen.height) - 40;
- var targetWidth;
- var targetHeight;
- targetWidth = $('#content').width();
- if (targetWidth > max) {
- targetWidth = max;
- }
- targetHeight = targetWidth * baseHeight / baseWidth;
- $('canvas').width(targetWidth);
- $('canvas').height(targetHeight);
- if (stage) {
- stage.canvas.width = targetWidth * dpr;
- stage.canvas.height = targetHeight * dpr;
- scale = dpr * targetWidth / baseWidth;
- stage.scaleX = scale;
- stage.scaleY = scale;
- stage.update();
- }
- }
- function doScaleResize() {
- var w;
- var targetWidth;
- var maxSize = Math.max(screen.width, screen.height);
- var minSize = Math.min(screen.width, screen.height);
- if (window.matchMedia("(orientation: portrait)").matches) {
- w = minSize - 40;
- } else {
- w = maxSize - 40;
- }
- var availableHeight = $(window).height() - $('#content').offset().top - 10;
- targetWidth = $('#content').width();
- if (targetWidth > w)
- targetWidth = w;
- var targetHeight = targetWidth * baseHeight / baseWidth;
- if (targetHeight > availableHeight) {
- targetHeight = availableHeight;
- targetWidth = targetHeight * baseWidth / baseHeight;
- }
- $('canvas').width(targetWidth);
- $('canvas').height(targetHeight);
- if (stage) {
- stage.canvas.width = targetWidth * dpr;
- stage.canvas.height = targetHeight * dpr;
- scale = dpr * targetWidth / baseWidth;
- stage.scaleX = scale;
- stage.scaleY = scale;
- stage.update();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement