主頁 > 後端開發 > HTML+CSS+JavaScript 實作圖片3D展覽

HTML+CSS+JavaScript 實作圖片3D展覽

2020-10-01 10:40:28 後端開發

文章目錄

      • 一、圖片3D展覽效果
      • 二、代碼實作
        • 1. HTML代碼
        • 2. CSS代碼
        • 3. JavaScript代碼

一、圖片3D展覽效果

上傳圖片的大小有限制,錄制的GIF圖展示效果不是很好
圖片3D展覽效果

錄屏的效果見鏈接:https://www.bilibili.com/video/BV1Bi4y1E7wk/

二、代碼實作

1. HTML代碼

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="HandheldFriendly" content="true">
    <meta name="description" content="圖片3D展覽屋">
    <meta name="keywords" content="canvas,3D_picture,perspective,texturing,gallery">
    <link href="res/slider-wb.css" rel="stylesheet">
    <title>圖片3D展覽屋</title>
    <style>
        html
        {
            overflow:visible;
            -ms-touch-action: none;
            -ms-content-zooming: none;
        }
        body
        {
            position: absolute;
            margin: 0px;
            padding: 0px;
            background: #fff;
            width: 100%;
            height: 100%;
        }
        #canvas
        {
            position: absolute;
            width: 100%;
            height: 100%;
            background: #fff;
        }
    </style>
    <script type="text/javascript" src="res/ge1doot.js"></script>
    <script type="text/javascript">

        "use strict";

        (function () {
            /* ==== definitions ==== */
            var diapo = [], layers = [], ctx, pointer, scr, camera, light, fps = 0, quality = [1, 2],
            // ---- poly constructor ----
	Poly = function (parent, face) {
	    this.parent = parent;
	    this.ctx = ctx;
	    this.color = face.fill || false;
	    this.points = [];
	    if (!face.img) {
	        // ---- create points ----
	        for (var i = 0; i < 4; i++) {
	            this.points[i] = new ge1doot.transform3D.Point(
					parent.pc.x + (face.x[i] * parent.normalZ) + (face.z[i] * parent.normalX),
					parent.pc.y + face.y[i],
					parent.pc.z + (face.x[i] * parent.normalX) + (-face.z[i] * parent.normalZ)
				);
	        }
	        this.points[3].next = false;
	    }
	},
            // ---- diapo constructor ----
	Diapo = function (path, img, structure) {
	    // ---- create image ----
	    this.img = new ge1doot.transform3D.Image(
			this, path + img.img, 1, {
			    isLoaded: function (img) {
			        img.parent.isLoaded = true;
			        img.parent.loaded(img);
			    }
			}
		);
	    this.visible = false;
	    this.normalX = img.nx;
	    this.normalZ = img.nz;
	    // ---- point center ----
	    this.pc = new ge1doot.transform3D.Point(img.x, img.y, img.z);
	    // ---- target positions ----
	    this.tx = img.x + (img.nx * Math.sqrt(camera.focalLength) * 20);
	    this.tz = img.z - (img.nz * Math.sqrt(camera.focalLength) * 20);
	    // ---- create polygons ----
	    this.poly = [];
	    for (var i = -1, p; p = structure[++i]; ) {
	        layers[i] = (p.img === true ? 1 : 2);
	        this.poly.push(
				new Poly(this, p)
			);
	    }
	},
            // ---- init section ----
	init = function (json) {
	    // draw poly primitive
	    Poly.prototype.drawPoly = ge1doot.transform3D.drawPoly;
	    // ---- init screen ----
	    scr = new ge1doot.Screen({
	        container: "canvas"
	    });
	    ctx = scr.ctx;
	    scr.resize();
	    // ---- init pointer ----
	    pointer = new ge1doot.Pointer({
	        tap: function () {
	            if (camera.over) {
	                if (camera.over === camera.target.elem) {
	                    // ---- return to the center ----
	                    camera.target.x = 0;
	                    camera.target.z = 0;
	                    camera.target.elem = false;
	                } else {
	                    // ---- goto diapo ----
	                    camera.target.elem = camera.over;
	                    camera.target.x = camera.over.tx;
	                    camera.target.z = camera.over.tz;
	                    // ---- adapt tesselation level to distance ----
	                    for (var i = 0, d; d = diapo[i++]; ) {
	                        var dx = camera.target.x - d.pc.x;
	                        var dz = camera.target.z - d.pc.z;
	                        var dist = Math.sqrt(dx * dx + dz * dz);
	                        var lev = (dist > 1500) ? quality[0] : quality[1];
	                        d.img.setLevel(lev);
	                    }
	                }
	            }
	        }
	    });
	    // ---- init camera ----
	    camera = new ge1doot.transform3D.Camera({
	        focalLength: Math.sqrt(scr.width) * 10,
	        easeTranslation: 0.025,
	        easeRotation: 0.06,
	        disableRz: true
	    }, {
	        move: function () {
	            this.over = false;
	            // ---- rotation ----
	            if (pointer.isDraging) {
	                this.target.elem = false;
	                this.target.ry = -pointer.Xi * 0.01;
	                this.target.rx = (pointer.Y - scr.height * 0.5) / (scr.height * 0.5);
	            } else {
	                if (this.target.elem) {
	                    this.target.ry = Math.atan2(
							this.target.elem.pc.x - this.x,
							this.target.elem.pc.z - this.z
						);
	                }
	            }
	            this.target.rx *= 0.9;
	        }
	    });
	    camera.z = -10000;
	    camera.py = 0;
	    // ---- create images ----
	    for (var i = 0, img; img = json.imgdata[i++]; ) {
	        diapo.push(
				new Diapo(
					json.options.imagesPath,
					img,
					json.structure
				)
			);
	    }
	    // ---- start engine ---- >>>
	    setInterval(function () {
	        quality = (fps > 50) ? [2, 3] : [1, 2];
	        fps = 0;
	    }, 1000);
	    run();
	},
            // ---- main loop ----
	run = function () {
	    // ---- clear screen ----
	    ctx.clearRect(0, 0, scr.width, scr.height);
	    // ---- camera ----
	    camera.move();
	    // ---- draw layers ----
	    for (var k = -1, l; l = layers[++k]; ) {
	        light = false;
	        for (var i = 0, d; d = diapo[i++]; ) {
	            (l === 1 && d.draw()) ||
				(d.visible && d.poly[k].draw());
	        }
	    }
	    // ---- cursor ----
	    if (camera.over && !pointer.isDraging) {
	        scr.setCursor("pointer");
	    } else {
	        scr.setCursor("move");
	    }
	    // ---- loop ----
	    fps++;
	    requestAnimFrame(run);
	};
            /* ==== prototypes ==== */
            Poly.prototype.draw = function () {
                // ---- color light ----
                var c = this.color;
                if (c.light || !light) {
                    var s = c.light ? this.parent.light : 1;
                    // ---- rgba color ----
                    light = "rgba(" +
				Math.round(c.r * s) + "," +
				Math.round(c.g * s) + "," +
				Math.round(c.b * s) + "," + (c.a || 1) + ")";
                    ctx.fillStyle = light;
                }
                // ---- paint poly ----
                if (!c.light || this.parent.light < 1) {
                    // ---- projection ----
                    for (
				var i = 0;
				this.points[i++].projection();
			);
                    this.drawPoly();
                    ctx.fill();
                }
            }
            /* ==== image onl oad ==== */
            Diapo.prototype.loaded = function (img) {
                // ---- create points ----
                var d = [-1, 1, 1, -1, 1, 1, -1, -1];
                var w = img.texture.width * 0.5;
                var h = img.texture.height * 0.5;
                for (var i = 0; i < 4; i++) {
                    img.points[i] = new ge1doot.transform3D.Point(
				this.pc.x + (w * this.normalZ * d[i]),
				this.pc.y + (h * d[i + 4]),
				this.pc.z + (w * this.normalX * d[i])
			);
                }
            }
            /* ==== images draw ==== */
            Diapo.prototype.draw = function () {
                // ---- visibility ----
                this.pc.projection();
                if (this.pc.Z > -(camera.focalLength >> 1) && this.img.transform3D(true)) {
                    // ---- light ----
                    this.light = 0.5 + Math.abs(this.normalZ * camera.cosY - this.normalX * camera.sinY) * 0.6;
                    // ---- draw image ----
                    this.visible = true;
                    this.img.draw();
                    // ---- test pointer inside ----
                    if (pointer.hasMoved || pointer.isDown) {
                        if (
					this.img.isPointerInside(
						pointer.X,
						pointer.Y
					)
				) camera.over = this;
                    }
                } else this.visible = false;
                return true;
            }
            return {
                // --- load data ----
                load: function (data) {
                    window.addEventListener('load', function () {
                        ge1doot.loadJS(
					"res/imageTransform3D.js",
					init, data
				);
                    }, false);
                }
            }
        })().load({
            imgdata: [
            // north
		{img: 'imgs/001.jpg', x: -1000, y: 0, z: 1500, nx: 0, nz: 1 },
		{ img: 'imgs/002.jpg', x: 0, y: 0, z: 1500, nx: 0, nz: 1 },
		{ img: 'imgs/003.jpg', x: 1000, y: 0, z: 1500, nx: 0, nz: 1 },
            // east
		{img: 'imgs/004.jpg', x: 1500, y: 0, z: 1000, nx: -1, nz: 0 },
		{ img: 'imgs/005.jpg', x: 1500, y: 0, z: 0, nx: -1, nz: 0 },
		{ img: 'imgs/006.jpg', x: 1500, y: 0, z: -1000, nx: -1, nz: 0 },
            // south
		{img: 'imgs/007.jpg', x: 1000, y: 0, z: -1500, nx: 0, nz: -1 },
		{ img: 'imgs/008.jpg', x: 0, y: 0, z: -1500, nx: 0, nz: -1 },
		{ img: 'imgs/009.jpg', x: -1000, y: 0, z: -1500, nx: 0, nz: -1 },
            // west
		{img: 'imgs/010.jpg', x: -1500, y: 0, z: -1000, nx: 1, nz: 0 },
		{ img: 'imgs/011.jpg', x: -1500, y: 0, z: 0, nx: 1, nz: 0 },
		{ img: 'imgs/012.jpg', x: -1500, y: 0, z: 1000, nx: 1, nz: 0 }
	],
            structure: [
		{
		    // wall
		    fill: { r: 255, g: 255, b: 255, light: 1 },
		    x: [-1001, -490, -490, -1001],
		    z: [-500, -500, -500, -500],
		    y: [500, 500, -500, -500]
		}, {
		    // wall
		    fill: { r: 255, g: 255, b: 255, light: 1 },
		    x: [-501, 2, 2, -500],
		    z: [-500, -500, -500, -500],
		    y: [500, 500, -500, -500]
		}, {
		    // wall
		    fill: { r: 255, g: 255, b: 255, light: 1 },
		    x: [0, 502, 502, 0],
		    z: [-500, -500, -500, -500],
		    y: [500, 500, -500, -500]
		}, {
		    // wall
		    fill: { r: 255, g: 255, b: 255, light: 1 },
		    x: [490, 1002, 1002, 490],
		    z: [-500, -500, -500, -500],
		    y: [500, 500, -500, -500]
		}, {
		    // shadow
		    fill: { r: 0, g: 0, b: 0, a: 0.2 },
		    x: [-420, 420, 420, -420],
		    z: [-500, -500, -500, -500],
		    y: [150, 150, -320, -320]
		}, {
		    // shadow
		    fill: { r: 0, g: 0, b: 0, a: 0.2 },
		    x: [-20, 20, 20, -20],
		    z: [-500, -500, -500, -500],
		    y: [250, 250, 150, 150]
		}, {
		    // shadow
		    fill: { r: 0, g: 0, b: 0, a: 0.2 },
		    x: [-20, 20, 20, -20],
		    z: [-500, -500, -500, -500],
		    y: [-320, -320, -500, -500]
		}, {
		    // shadow
		    fill: { r: 0, g: 0, b: 0, a: 0.2 },
		    x: [-20, 20, 10, -10],
		    z: [-500, -500, -100, -100],
		    y: [-500, -500, -500, -500]
		}, {
		    // base
		    fill: { r: 32, g: 32, b: 32 },
		    x: [-50, 50, 50, -50],
		    z: [-150, -150, -50, -50],
		    y: [-500, -500, -500, -500]
		}, {
		    // support
		    fill: { r: 16, g: 16, b: 16 },
		    x: [-10, 10, 10, -10],
		    z: [-100, -100, -100, -100],
		    y: [300, 300, -500, -500]
		}, {
		    // frame
		    fill: { r: 255, g: 255, b: 255 },
		    x: [-320, -320, -320, -320],
		    z: [0, -20, -20, 0],
		    y: [-190, -190, 190, 190]
		}, {
		    // frame
		    fill: { r: 255, g: 255, b: 255 },
		    x: [320, 320, 320, 320],
		    z: [0, -20, -20, 0],
		    y: [-190, -190, 190, 190]
		},
		{ img: true },
		{
		    // ceilingLight
		    fill: { r: 255, g: 128, b: 0 },
		    x: [-50, 50, 50, -50],
		    z: [450, 450, 550, 550],
		    y: [500, 500, 500, 500]
		}, {
		    // groundLight
		    fill: { r: 255, g: 128, b: 0 },
		    x: [-50, 50, 50, -50],
		    z: [450, 450, 550, 550],
		    y: [-500, -500, -500, -500]
		}
	],
            options: {
                imagesPath: ""
            }
        });
</script>
</head>
<body>
<a href="https://blog.csdn.net/fyfugoyfa/article/details/108153075" target="_blank">CSDN文章</a><br />
    <canvas id="canvas">建議用谷歌瀏覽器打開</canvas>
</body>
</html>

2. CSS代碼

#icon {
	background: rgb(255, 144, 0); border-radius: 6px 0px 0px; transition:0.6s ease-in-out; left: 65px; top: 6px; width: 40px; height: 40px; overflow: hidden; position: relative; cursor: pointer; -moz-transition: all 0.6s ease-in-out 0s; -webkit-transition: all 0.6s ease-in-out 0s; -o-transition: all 0.6s ease-in-out 0s;
}
#icon div {
	background: none; position: absolute;
}
#icon div:nth-child(1) {
	border-width: 7px 0px 7px 8px; border-style: solid; border-color: transparent rgb(255, 255, 255); left: 20px; top: 50%; width: 0px; height: 0px; margin-top: -7px; position: absolute;
}
#icon div:nth-child(2) {
	background: rgb(255, 255, 255); left: 12px; top: 50%; width: 8px; height: 6px; margin-top: -3px; position: absolute;
}
#nav {
	top: 10px; width: 100px; height: 0px; position: absolute; -ms-user-select: none; -webkit-user-select: none; -moz-user-select: none;
}
#nav-switch {
	display: none;
}
#nav .label {
	display: block; cursor: pointer;
}
#nav .container {
	transition:left 0.3s ease-in-out; left: -100px; width: 100%; position: absolute; -moz-transition: left 0.3s ease-in-out 0s; -webkit-transition: left 0.3s ease-in-out 0s; -o-transition: left 0.3s ease-in-out 0s;
}
#nav .container > div {
	padding: 0px; width: 50%; float: left;
}
#nav .container .nav-on {
	color: rgb(51, 51, 51); padding-left: 0px;
}
#nav .container .nav-off {
	width: 40px; height: 40px; padding-right: 10px;
}
:checked#nav-switch + .label .container {
	left: 10px;
}
:checked#nav-switch + .label #icon {
	background: rgb(0, 101, 203); border-radius: 0px 0px 6px; transform: rotate(-180deg); -webkit-transform: rotate(-180deg); -moz-transform: rotate(-180deg); -o-transform: rotate(-180deg);
}
.title {
	margin: 0px; padding: 0px; left: 170px; top: 2px; height: 40px; color: rgb(51, 51, 51); line-height: 40px; font-family: "Segoe UI Light", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; font-size: 24px; font-weight: bold; white-space: nowrap; position: absolute; -ms-user-select: none; -webkit-user-select: none; -moz-user-select: none; -o-user-select: none; user-select: none;
}
.menu {
	margin: 0px; padding: 0px; left: 0px; top: 6px; color: rgb(51, 51, 51); font-family: "Segoe UI Light", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; font-size: 1em; font-weight: lighter; list-style-type: none; position: relative; cursor: pointer;
}
.menu li {
	list-style: none; width: 100px; height: 40px; border-right-color: rgb(221, 221, 221); border-right-width: 1px; border-right-style: solid; position: relative; cursor: pointer;
}
.menu a {
	color: rgb(51, 51, 51); line-height: 40px; padding-left: 40px; text-decoration: none; display: block; position: relative;
}
.menu li a:hover {
	background: rgb(255, 144, 0);
}
.menu li a:focus {
	background: rgb(255, 144, 0);
}
.menu li a:active {
	background: rgb(255, 144, 0);
}
#nav li::before {
	top: 50%; margin-left: 10px; position: absolute; content: "";
}
#nav li::after {
	top: 50%; margin-left: 10px; position: absolute; content: "";
}
#nav li a::before {
	top: 50%; margin-left: 10px; position: absolute; content: "";
}
#nav li a::after {
	top: 50%; margin-left: 10px; position: absolute; content: "";
}
#nav .home a::before {
	border-width: 8px 7px; border-style: solid; border-color: transparent transparent rgb(51, 51, 51); left: 2px; margin-top: -16px;
}
#nav .home a::after {
	border-width: 3px 4px 0px; border-style: solid; border-color: rgb(51, 51, 51) rgb(51, 51, 51) transparent; left: 4px; width: 2px; height: 4px; margin-top: 0px;
}
#nav .arrow a::before {
	border-width: 7px 0px 7px 8px; border-style: solid; border-color: transparent rgb(51, 51, 51); left: 8px; margin-top: -7px;
}
#nav .arrow a::after {
	background: rgb(51, 51, 51); left: 0px; width: 8px; height: 6px; margin-top: -3px;
}
#nav .back.arrow a::before {
	border-width: 7px 8px 7px 0px; left: 0px;
}
#nav .back.arrow a::after {
	left: 8px;
}
#nav .list a::before {
	background: none; border-width: 6px 0px; border-style: double; border-color: rgb(51, 51, 51); left: 5px; top: 14px; width: 12px; height: 2px;
}
#nav .list a::after {
	background: none; border-width: 6px 0px; border-style: double; border-color: rgb(51, 51, 51); left: 1px; top: 14px; width: 2px; height: 2px;
}

3. JavaScript代碼

// ===== ge1doot global =====    js檔案1
var ge1doot = ge1doot || {
	json: null,
	screen: null,
	pointer: null,
	camera: null,
	loadJS: function (url, callback, data) {
		if (typeof url == "string") url = [url];
		var load = function (src) {
			var script = document.createElement("script");
				if (callback) {
					if (script.readyState){
						script.onreadystatechange = function () {
							if (script.readyState == "loaded" || script.readyState == "complete"){
								script.onreadystatechange = null;
								if (--n === 0) callback(data || false);
							}
						}
					} else {
						script.onload = function() {
							if (--n === 0) callback(data || false);
						}
					}
				}
				script.src = src;
				document.getElementsByTagName("head")[0].appendChild(script);
		}
		for (var i = 0, n = url.length; i < n; i++) load(url[i]);
	}
}

// ===== html/canvas container =====
ge1doot.Screen = function (setup) {
	ge1doot.screen = this;
	this.elem = document.getElementById(setup.container) || setup.container;
	this.ctx = this.elem.tagName == "CANVAS" ? this.elem.getContext("2d") : false;
	this.style = this.elem.style;
	this.left = 0;
	this.top = 0;
	this.width = 0;
	this.height = 0;
	this.cursor = "default";
	this.setup = setup;
	this.resize = function () {
		var o = this.elem;
		this.width  = o.offsetWidth;
		this.height = o.offsetHeight;
		for (this.left = 0, this.top = 0; o != null; o = o.offsetParent) {
			this.left += o.offsetLeft;
			this.top  += o.offsetTop;
		}
		if (this.ctx) {
			this.elem.width  = this.width;
			this.elem.height = this.height;
		}
		this.setup.resize && this.setup.resize();
	}
	this.setCursor = function (type) {
		if (type !== this.cursor && 'ontouchstart' in window === false) {
			this.cursor = type;
			this.style.cursor = type;
		}
	}
	window.addEventListener('resize', function () {
		ge1doot.screen.resize();
	}, false);
	!this.setup.resize && this.resize();
}

// ==== unified touch events handler ====
ge1doot.Pointer = function (setup) {
	ge1doot.pointer = this;
	var self        = this;
	var body        = document.body;
	var html        = document.documentElement;
	this.setup      = setup;
	this.screen     = ge1doot.screen;
	this.elem       = this.screen.elem;
	this.X          = 0;
	this.Y          = 0;
	this.Xi         = 0;
	this.Yi         = 0;
	this.bXi        = 0;
	this.bYi        = 0;
	this.Xr         = 0;
	this.Yr         = 0;
	this.startX     = 0;
	this.startY     = 0;
	this.scale      = 0;
	this.wheelDelta = 0;
	this.isDraging  = false;
	this.hasMoved   = false;
	this.isDown     = false;
	this.evt        = false;
	var sX          = 0;
	var sY          = 0;
	// prevent default behavior
	if (setup.tap) this.elem.onclick = function () { return false; }
	if (!setup.documentMove) {
		document.ontouchmove = function(e) { e.preventDefault(); }
	}
	document.addEventListener("MSHoldVisual", function(e) { e.preventDefault(); }, false);
	if (typeof this.elem.style.msTouchAction != 'undefined') this.elem.style.msTouchAction = "none";

	this.pointerDown = function (e) {
		if (!this.isDown) {
			if (this.elem.setCapture) this.elem.setCapture();
			this.isDraging = false;
			this.hasMoved = false;
			this.isDown = true;
			this.evt = e;
			this.Xr = (e.clientX !== undefined ? e.clientX : e.touches[0].clientX);
			this.Yr = (e.clientY !== undefined ? e.clientY : e.touches[0].clientY);
			this.X  = sX = this.Xr - this.screen.left;
			this.Y  = sY = this.Yr - this.screen.top + ((html && html.scrollTop) || body.scrollTop);
			this.setup.down && this.setup.down(e);
		}
	}
	this.pointerMove = function(e) {
		this.Xr = (e.clientX !== undefined ? e.clientX : e.touches[0].clientX);
		this.Yr = (e.clientY !== undefined ? e.clientY : e.touches[0].clientY);
		this.X  = this.Xr - this.screen.left;
		this.Y  = this.Yr - this.screen.top + ((html && html.scrollTop) || body.scrollTop);
		if (this.isDown) {
			this.Xi = this.bXi + (this.X - sX);
			this.Yi = this.bYi - (this.Y - sY);
		}
		if (Math.abs(this.X - sX) > 11 || Math.abs(this.Y - sY) > 11) {
			this.hasMoved = true;
			if (this.isDown) {
				if (!this.isDraging) {
					this.startX = sX;
					this.startY = sY;
					this.setup.startDrag && this.setup.startDrag(e);
					this.isDraging = true;
				} else {
					this.setup.drag && this.setup.drag(e);
				}
			} else {
				sX = this.X;
				sY = this.Y;
			}
		}
		this.setup.move && this.setup.move(e);
	}
	this.pointerUp = function(e) {
		this.bXi = this.Xi;
		this.bYi = this.Yi;
		if (!this.hasMoved) {
			this.X = sX;
			this.Y = sY;
			this.setup.tap && this.setup.tap(this.evt);
		} else {
			this.setup.up && this.setup.up(this.evt);
		}
		this.isDraging = false;
		this.isDown = false;
		this.hasMoved = false;
		this.setup.up && this.setup.up(this.evt);
		if (this.elem.releaseCapture) this.elem.releaseCapture();
		this.evt = false;
	}
	this.pointerCancel = function(e) {
		if (this.elem.releaseCapture) this.elem.releaseCapture();
		this.isDraging = false;
		this.hasMoved = false;
		this.isDown = false;
		this.bXi = this.Xi;
		this.bYi = this.Yi;
		sX = 0;
		sY = 0;
	}
	if ('ontouchstart' in window) {
		this.elem.ontouchstart      = function (e) { self.pointerDown(e); return false;  }
		this.elem.ontouchmove       = function (e) { self.pointerMove(e); return false;  }
		this.elem.ontouchend        = function (e) { self.pointerUp(e); return false;    }
		this.elem.ontouchcancel     = function (e) { self.pointerCancel(e); return false;}
	}
	document.addEventListener("mousedown", function (e) {
		if (
			e.target === self.elem || 
			(e.target.parentNode && e.target.parentNode === self.elem) || 
			(e.target.parentNode.parentNode && e.target.parentNode.parentNode === self.elem)
		) {
			if (typeof e.stopPropagation != "undefined") {
				e.stopPropagation();
			} else {
				e.cancelBubble = true;
			}
			e.preventDefault();
			self.pointerDown(e); 
		}
	}, false);
	document.addEventListener("mousemove", function (e) { self.pointerMove(e); }, false);
	document.addEventListener("mouseup",   function (e) {
		self.pointerUp(e);
	}, false);
	document.addEventListener('gesturechange', function(e) {
		e.preventDefault();
		if (e.scale > 1) self.scale = 0.1; else if (e.scale < 1) self.scale = -0.1; else self.scale = 0;
		self.setup.scale && self.setup.scale(e);
		return false;
	}, false);
	if (window.navigator.msPointerEnabled) {
		var nContact = 0;
		var myGesture = new MSGesture();
		myGesture.target = this.elem;
		this.elem.addEventListener("MSPointerDown", function(e) {
			if (e.pointerType == e.MSPOINTER_TYPE_TOUCH) {
				myGesture.addPointer(e.pointerId);
				nContact++;
			}
		}, false);
		this.elem.addEventListener("MSPointerOut", function(e) {
			if (e.pointerType == e.MSPOINTER_TYPE_TOUCH) {
				nContact--;
			}
		}, false);
		this.elem.addEventListener("MSGestureHold", function(e) {
			e.preventDefault();
		}, false);
		this.elem.addEventListener("MSGestureChange", function(e) {
			if (nContact > 1) {
				if (e.preventDefault) e.preventDefault(); 
				self.scale = e.velocityExpansion;
				self.setup.scale && self.setup.scale(e);
			}
			return false;
		}, false);
	}
	if (window.addEventListener) this.elem.addEventListener('DOMMouseScroll', function(e) { 
		if (e.preventDefault) e.preventDefault(); 
		self.wheelDelta = e.detail * 10;
		self.setup.wheel && self.setup.wheel(e);
		return false; 
	}, false); 
	this.elem.onmousewheel = function () { 
		self.wheelDelta = -event.wheelDelta * .25;
		self.setup.wheel && self.setup.wheel(event);
		return false; 
	}
}

// ===== request animation frame =====
window.requestAnimFrame = (function(){
		return  window.requestAnimationFrame || 
		window.webkitRequestAnimationFrame   || 
		window.mozRequestAnimationFrame      || 
		window.oRequestAnimationFrame        || 
		window.msRequestAnimationFrame       || 
		function( run ){
			window.setTimeout(run, 16);
		};
})();

/* ====== js檔案2 ======= */
"use strict";

var ge1doot = ge1doot || {};
ge1doot.transform3D = {};

/* ==== draw Poly ==== */   
ge1doot.transform3D.drawPoly = function () {
	this.ctx.beginPath();
	this.ctx.moveTo(this.points[0].X, this.points[0].Y);
	this.ctx.lineTo(this.points[1].X, this.points[1].Y);
	this.ctx.lineTo(this.points[2].X, this.points[2].Y);
	this.ctx.lineTo(this.points[3].X, this.points[3].Y);
	this.ctx.closePath();
}

/* =============== camera constructor ================= */
ge1doot.transform3D.Camera = function (setup, func) {
	ge1doot.camera = this;
	this.x  = 0;
	this.y  = 0;
	this.z  = 0;
	this.rx = 0;
	this.ry = 0;
	this.rz = 0;
	this.focalLength     = setup.focalLength || 500;
	this.easeTranslation = setup.easeTranslation || 0.1;
	this.easeRotation    = setup.easeRotation || 0.025;
	this.enableRx        = setup.disableRx ? false : true;
	this.enableRy        = setup.disableRy ? false : true;
	this.enableRz        = setup.disableRz ? false : true;
	this.cmov = false;
	this.cosX = 1;
	this.sinX = 0;
	this.cosY = 1;
	this.sinY = 0;
	this.cosZ = 1;
	this.sinZ = 0;
	this.target = {
		over: false,
		elem: false,
		x:  0,
		y:  0,
		z:  0,
		rx: 0,
		ry: 0,
		rz: 0
	};
	// ---- def custom move ----
	if (func && func.move) this.cmov = func.move;
}

/* ==== easing ==== */
ge1doot.transform3D.Camera.prototype.ease = function (target, value) {
	while (Math.abs(target - value) > Math.PI) {
		if (target < value)  value -= 2 * Math.PI;
		else value += 2 * Math.PI;
	}
	return (target - value) * this.easeRotation;
}

/* ==== move / rotate camera ==== */
ge1doot.transform3D.Camera.prototype.move = function () {
	// ---- run custom function ----
	this.cmov && this.cmov();
	// ---- translations ----
	this.x += (this.target.x - this.x) * this.easeTranslation;
	this.y += (this.target.y - this.y) * this.easeTranslation;
	this.z += (this.target.z - this.z) * this.easeTranslation;
	// ---- rotation rx ----
	if (this.enableRx) {
		this.rx += this.ease(this.target.rx, this.rx);
		this.cosX = Math.cos(this.rx);
		this.sinX = Math.sin(this.rx);
	}
	// ---- rotation ry ----
	if (this.enableRy) {
		this.ry += this.ease(this.target.ry, this.ry);
		this.cosY = Math.cos(this.ry);
		this.sinY = Math.sin(this.ry);
	}
	// ---- rotation rz ----
	if (this.enableRz) {
		this.rz += this.ease(this.target.rz, this.rz);
		this.cosZ = Math.cos(this.rz);
		this.sinZ = Math.sin(this.rz);
	}
}

/* =============== point constructor ================= */
ge1doot.transform3D.Point = function (x, y, z, tx, ty) {
	this.x = x;
	this.y = y;
	this.z = z;
	this.tx = tx || 0;
	this.ty = ty || 0;
	this.visible = false;
	this.scale = 0;
	this.X = 0;
	this.Y = 0;
	this.Z = 0;
	this.next = true;
}

/* ==== perspective projection ==== */
ge1doot.transform3D.Point.prototype.projection = function () {
	var sw       = this.scr.width  >> 1;
	var sh       = this.scr.height >> 1;
	// ---- 3D coordinates ----
	var nx       = this.x - this.camera.x;
	var ny       = this.y - this.camera.y;
	var nz       = this.z - this.camera.z;
	// ---- 3D rotation and projection ----
	if (this.camera.enableRz) {
		var u = this.camera.sinZ * ny + this.camera.cosZ * nx;
		var t = this.camera.cosZ * ny - this.camera.sinZ * nx;
	} else {
		var u = nx;
		var t = ny;
	}
	var s        = this.camera.cosY * nz + this.camera.sinY * u;
	this.Z       = this.camera.cosX * s  - this.camera.sinX * t;
	this.scale   = this.camera.focalLength / Math.max(1, this.Z);
	this.X       = sw + (this.camera.cosY * u  - this.camera.sinY * nz) * this.scale;
	this.Y       = -(this.camera.y >> 1) + sh - (this.camera.sinX * s  + this.camera.cosX * t) * this.scale;
	// ---- visibility test ----
	this.visible = (
		this.X > -sw * 0.5 && this.X < sw * 2.5
	) && (
		this.Y > -sh * 0.5 && this.Y < sh * 2.5
	);
	// ----return next (fast loop) ----
	return this.next;
}

/* ==== triangle constructor ==== */
ge1doot.transform3D.Triangle = function (parent, p0, p1, p2) {
	this.ctx = parent.ctx;
	this.texture = parent.texture;
	this.p0  = p0;
	this.p1  = p1;
	this.p2  = p2;
	this.d   = p0.tx * (p2.ty - p1.ty) - p1.tx * p2.ty + p2.tx * p1.ty + (p1.tx - p2.tx) * p0.ty;
	this.pmy = p1.ty - p2.ty;
	this.pmx = p1.tx - p2.tx;
	this.pxy = p2.tx * p1.ty - p1.tx * p2.ty;
	if (parent.t) parent.t.next = true;
}

/* ==== draw triangle ==== */
ge1doot.transform3D.Triangle.prototype.draw = function () {
	if (this.p0.visible || this.p1.visible || this.p2.visible) {
		var dx, dy, d;
		// ---- centroid ----
		var xc = (this.p0.X + this.p1.X + this.p2.X) / 3;
		var yc = (this.p0.Y + this.p1.Y + this.p2.Y) / 3;
		// ---- clipping ----
		this.ctx.save();
		this.ctx.beginPath();
		dx = xc - this.p0.X;
		dy = yc - this.p0.Y;
		d = Math.max(Math.abs(dx), Math.abs(dy));
		this.ctx.moveTo(this.p0.X - 2 * (dx / d), this.p0.Y - 2 * (dy / d));
		dx = xc - this.p1.X;
		dy = yc - this.p1.Y;
		d = Math.max(Math.abs(dx), Math.abs(dy));
		this.ctx.lineTo(this.p1.X - 2 * (dx / d), this.p1.Y - 2 * (dy / d));
		dx = xc - this.p2.X;
		dy = yc - this.p2.Y;
		d = Math.max(Math.abs(dx), Math.abs(dy));
		this.ctx.lineTo(this.p2.X - 2 * (dx / d), this.p2.Y - 2 * (dy / d));
		this.ctx.closePath();
		this.ctx.clip();
		// ---- transform ----
		var t0 = this.p2.X  - this.p1.X,
			t1 = this.p1.Y  - this.p2.Y,
			t2 = this.p2.ty * this.p1.X,
			t3 = this.p1.tx * this.p2.X,
			t4 = this.p2.ty * this.p1.Y,
			t5 = this.p1.ty * this.p2.X,
			t6 = this.p1.ty * this.p2.Y,
			t7 = this.p2.tx * this.p1.X,
			t8 = this.p1.tx * this.p2.Y,
			t9 = this.p2.tx * this.p1.Y;
		this.ctx.transform(
			-(this.p0.ty * t0 - t5 + t2 + this.pmy * this.p0.X) / this.d, // m11
			 (t6 + this.p0.ty * t1 - t4 - this.pmy * this.p0.Y) / this.d, // m12
			 (this.p0.tx * t0 - t3 + t7 + this.pmx * this.p0.X) / this.d, // m21
			-(t8 + this.p0.tx * t1 - t9 - this.pmx * this.p0.Y) / this.d, // m22
			 (this.p0.tx * (t2 - t5) + this.p0.ty * (t3 - t7) + this.pxy * this.p0.X) / this.d, // dx
			 (this.p0.tx * (t4 - t6) + this.p0.ty * (t8 - t9) + this.pxy * this.p0.Y) / this.d  // dy
		);
		// ---- draw ----
		this.ctx.drawImage(this.texture, 0, 0);
		this.ctx.restore();
	}
	return this.next;
}

/* ===================== image constructor ========================== */
ge1doot.transform3D.Image = function (parent, imgSrc, lev, callback) {
	this.parent        = parent;
	this.points        = [];
	this.triangles     = [];
	this.ctx           = ge1doot.screen.ctx;
	this.pointer       = ge1doot.pointer;
	this.texture       = new Image();
	this.texture.src   = imgSrc;
	this.isLoading     = true;
	this.callback      = callback;
	this.textureWidth  = 0;
	this.textureHeight = 0;
	this.level         = lev || 1;
	this.visible       = false;
	this.t             = false;
	if (!ge1doot.transform3D.Point.prototype.scr) {
		ge1doot.transform3D.Point.prototype.scr    = ge1doot.screen;
		ge1doot.transform3D.Point.prototype.camera = ge1doot.camera;
	}
}

/* ==== drawPoly prototype ==== */
ge1doot.transform3D.Image.prototype.drawPoly = ge1doot.transform3D.drawPoly;

/* ==== change tessellation level prototype ==== */
ge1doot.transform3D.Image.prototype.setLevel = function (level) {
	this.points.length = 0;
	this.triangles.length = 0;
	this.level = level;
	this.loading();
}

/* ==== loading prototype ==== */
ge1doot.transform3D.Image.prototype.loading = function () {
	if (this.texture.complete) {
		var dir = [0,1,1,0,0,0,1,1];
		this.isLoading = false;
		// ---- image size ----
		this.textureWidth = this.texture.width;
		this.textureHeight = this.texture.height;
		// ---- isLoaded callback ---
		this.callback && this.callback.isLoaded && this.callback.isLoaded(this);
		// ---- texture position ----
		for (var i = -1, p; p = this.points[++i];) {
			p.tx = this.textureWidth  * dir[i];
			p.ty = this.textureHeight * dir[i+4];
		}
		// ---- triangularization ----
		this.triangulate(this.points[0], this.points[1], this.points[2], this.level);
		this.triangulate(this.points[0], this.points[2], this.points[3], this.level);
		// ---- last point ----
		this.points[this.points.length - 1].next = false;
	}
}

/* ==== vector bisection function ==== */
ge1doot.transform3D.Image.prototype.subdivise = function (p0, p1) {
	return {
		x:  (p1.x + p0.x)   * 0.5,
		y:  (p1.y + p0.y)   * 0.5,
		z:  (p1.z + p0.z)   * 0.5,
		tx: (p1.tx + p0.tx) * 0.5,
		ty: (p1.ty + p0.ty) * 0.5
	};
}

/* ==== triangulation ==== */
ge1doot.transform3D.Image.prototype.triangulate = function (p0, p1, p2, level) {
	level--;
	if (level === 0) {
		// final triangle
		this.t = new ge1doot.transform3D.Triangle(this, p0, p1, p2);
		this.triangles.push(this.t);
	} else {
		// ---- subdivision ----
		var p01 = this.subdivise(p0, p1);
		var p12 = this.subdivise(p1, p2);
		var p20 = this.subdivise(p2, p0);
		// ---- insert new points ----
		this.points.push(p01 = new ge1doot.transform3D.Point(p01.x, p01.y, p01.z, p01.tx, p01.ty));
		this.points.push(p12 = new ge1doot.transform3D.Point(p12.x, p12.y, p12.z, p12.tx, p12.ty));
		this.points.push(p20 = new ge1doot.transform3D.Point(p20.x, p20.y, p20.z, p20.tx, p20.ty));
		// ---- recursive triangulation ----
		this.triangulate(p0,   p01,  p20, level);
		this.triangulate(p01,  p1,   p12, level);
		this.triangulate(p20,  p12,  p2,  level);
		this.triangulate(p01,  p12,  p20, level);
	}
}

/* ==== transform prototype ==== */
ge1doot.transform3D.Image.prototype.transform3D = function (backfaceTest) {
	if (this.isLoading) {
		// ---- image is loading ----
		this.loading();
		return false;
	} else {
		// ---- project points ----
		for (
			var i = 0;
			this.points[i++].projection();
		);
		if (backfaceTest) {
			var p0 = this.points[0];
			var p1 = this.points[1];
			var p2 = this.points[2];
			return (
				((p1.Y - p0.Y) / (p1.X - p0.X) - 
				(p2.Y - p0.Y) / (p2.X - p0.X) < 0) ^ 
				(p0.X <= p1.X == p0.X > p2.X)
			);
		} else return true;
	}
}

/* ==== draw prototype ==== */
ge1doot.transform3D.Image.prototype.draw = function () {
	if (!this.isLoading) {
		// ---- draw triangles ----
		for (
			var i = 0;
			this.triangles[i++].draw();
		);
	}
}

/* ==== isPointerInside prototype ==== */
ge1doot.transform3D.Image.prototype.isPointerInside = function (x, y) {
	this.drawPoly(this.points);
	return this.ctx.isPointInPath(x, y);
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/144886.html

標籤:java

上一篇:2020-09-30

下一篇:基于Jenkins、Node.js、碼云和Shell的Vue前端自動化部署

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more