国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

利用html做一個3D 圖片動態(tài)效果

這篇具有很好參考價值的文章主要介紹了利用html做一個3D 圖片動態(tài)效果。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

今天分享一個3D圖片動態(tài)效果

不多廢話上代碼

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Wanna tell her - interactive DHTML</title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
html {
overflow: hidden;
}
body {
position: absolute;
margin: 0px;
padding: 0px;
background: #fff;
width: 100%;
height: 100%;
}
#screen {
position: absolute;
left: 10%;
top: 10%;
width: 80%;
height: 80%;
background: #fff;
}
#screen img {
position: absolute;
cursor: pointer;
width: 0px;
height: 0px;
-ms-interpolation-mode:nearest-neighbor;
}
#bankImages {
visibility: hidden;
}
#FPS {
position: absolute;
right: 5px;
bottom: 5px;
font-size: 10px;
color: #666;
font-family: verdana;
}

</style>

<script type="text/javascript">
/* ==== Easing function ==== */
var Library = {};
Library.ease = function () {
this.target = 0;
this.position = 0;
this.move = function (target, speed) {
this.position += (target - this.position) * speed;
}
}

var tv = {
/* ==== variables ==== */
O : [],
fps : 0,
screen : {},
angle : {
x : new Library.ease(),
y : new Library.ease()
},
camera : {
x : new Library.ease(),
y : new Library.ease()
},
create3DHTML : function (i, x, y, z, sw, sh) {
/* ==== create HTML image element ==== */
var o = document.createElement('img');
o.src = i.src;
tv.screen.obj.appendChild(o);
/* ==== 3D coordinates ==== */
o.point3D = {
x : x,
y : y,
z : new Library.ease(),
sw : sw,
sh : sh,
w : i.width,
h : i.height
};
o.point3D.z.target = z;
/* ==== push object ==== */
o.point2D = {};
tv.O.push(o);

/* ==== on mouse over event ==== */
o.onmouseover = function () {
if (this != tv.o) {
this.point3D.z.target = tv.mouseZ;
tv.camera.x.target = this.point3D.x;
tv.camera.y.target = this.point3D.y;
if (tv.o) tv.o.point3D.z.target = 0;
tv.o = this;
}
return false;
}

/* ==== on mousedown event ==== */
o.onmousedown = function () {
if (this == tv.o) {
if (this.point3D.z.target == tv.mouseZ) this.point3D.z.target = 0;
else {
tv.o = false;
this.onmouseover();
}
}
}

/* ==== main 3D function ==== */
o.animate = function () {
/* ==== 3D coordinates ==== */
var x = this.point3D.x - tv.camera.x.position;
var y = this.point3D.y - tv.camera.y.position;
this.point3D.z.move(this.point3D.z.target, this.point3D.z.target ? .15 : .08);
/* ==== rotations ==== */
var xy = tv.angle.cx * y - tv.angle.sx * this.point3D.z.position;
var xz = tv.angle.sx * y + tv.angle.cx * this.point3D.z.position;
var yz = tv.angle.cy * xz - tv.angle.sy * x;
var yx = tv.angle.sy * xz + tv.angle.cy * x;
/* ==== 2D transform ==== */
var scale = tv.camera.focalLength / (tv.camera.focalLength + yz);
x = yx * scale;
y = xy * scale;
var w = Math.round(Math.max(0, this.point3D.w * scale * this.point3D.sw));
var h = Math.round(Math.max(0, this.point3D.h * scale * this.point3D.sh));
/* ==== HTML rendering ==== */
var o = this.style;
o.left = Math.round(x + tv.screen.w - w * .5) + 'px';
o.top = Math.round(y + tv.screen.h - h * .5) + 'px';
o.width = w + 'px';
o.height = h + 'px';
o.zIndex = 10000 + Math.round(scale * 1000);
}
},

/* ==== init script ==== */
init : function (structure, FL, mouseZ, rx, ry) {
this.screen.obj = document.getElementById('screen');
this.screen.obj.onselectstart = function () { return false; }
this.screen.obj.ondrag = function () { return false; }
this.mouseZ = mouseZ;
this.camera.focalLength = FL;
this.angle.rx = rx;
this.angle.ry = ry;
/* ==== create objects ==== */
var i = 0, o;
while( o = structure[i++] )
this.create3DHTML(o.img, o.x, o.y, o.z, o.sw, o.sh);
/* ==== start script ==== */
this.resize();
mouse.y = this.screen.y + this.screen.h;
mouse.x = this.screen.x + this.screen.w;
/* ==== loop ==== */
setInterval(tv.run, 16);
setInterval(tv.dFPS, 1000);
},

/* ==== resize window ==== */
resize : function () {
var o = tv.screen.obj;
if (o) {
tv.screen.w = o.offsetWidth / 2;
tv.screen.h = o.offsetHeight / 2;
for (tv.screen.x = 0, tv.screen.y = 0; o != null; o = o.offsetParent) {
tv.screen.x += o.offsetLeft;
tv.screen.y += o.offsetTop;
}
}
},

/* ==== main loop ==== */
run : function () {
tv.fps++;
/* ==== motion ease ==== */
tv.angle.x.move(-(mouse.y - tv.screen.h - tv.screen.y) * tv.angle.rx, .1);
tv.angle.y.move( (mouse.x - tv.screen.w - tv.screen.x) * tv.angle.ry, .1);
tv.camera.x.move(tv.camera.x.target, .025);
tv.camera.y.move(tv.camera.y.target, .025);
/* ==== angles sin and cos ==== */
tv.angle.cx = Math.cos(tv.angle.x.position);
tv.angle.sx = Math.sin(tv.angle.x.position);
tv.angle.cy = Math.cos(tv.angle.y.position);
tv.angle.sy = Math.sin(tv.angle.y.position);
/* ==== loop through images ==== */
var i = 0, o;
while( o = tv.O[i++] ) o.animate();
},

/* ==== trace frames per seconds ==== */
dFPS : function () {
document.getElementById('FPS').innerHTML = tv.fps + ' FPS';
tv.fps = 0;
}
}

/* ==== global mouse position ==== */
var mouse = {
x : 0,
y : 0
}
document.onmousemove = function(e) {
if (window.event) e = window.event;
mouse.x = e.clientX;
mouse.y = e.clientY;
return false;
}

/* ==== starting script ==== */
onload = function() {
onresize = tv.resize;
/* ==== build grid ==== */
var img = document.getElementById('bankImages').getElementsByTagName('img');
var structure = [];
for (var i = -300; i <= 300; i += 120)
for (var j = -300; j <= 300; j += 120)
structure.push({ img:img[0], x:i, y:j, z:0, sw:.5, sh:.5 });
/* ==== let's go ==== */
tv.init(structure, 350, -200, .005, .0025);
}

</script>
</head>

<body>

<div id="screen"></div>

<div id="bankImages">
<img alt="" src="https://img.lanrentuku.com/img/allimg/1702/14866915555054.gif">
</div>
<div id="FPS"></div>

</body>
</html>

在倒數(shù)第6行src=后是圖片地址 可以自行更改

如有侵權(quán)請聯(lián)系352648773@qq.com郵箱

插一條:如果有人想要一些好玩的腳本(vbs,bat,html)同樣聯(lián)系我郵箱文章來源地址http://www.zghlxwxcb.cn/news/detail-513088.html

到了這里,關(guān)于利用html做一個3D 圖片動態(tài)效果的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • html掉落本地圖片效果

    html掉落本地圖片效果

    實現(xiàn)一個加載本地圖片并掉落的html頁面。 說明 將 DuanWu.html 與 zongzi_1.png, zongzi_2.png, zongzi_3.png, yadan.png 4張圖片放在同一個目錄下,然后雙擊打開 DuanWu.html 即可。 使用 Chrome 或 Microsoft Edge 瀏覽器打開 若使用 IE 瀏覽器打開,下方會出現(xiàn) Internet Explorer已限制此網(wǎng)頁運行腳本或A

    2024年02月12日
    瀏覽(17)
  • HTML實現(xiàn)圖片點擊放大效果

    1.樣式 2.圖片和遮罩層 3.效果實現(xiàn)代碼

    2024年02月11日
    瀏覽(21)
  • HTML/CSS實現(xiàn)3D翻轉(zhuǎn)頁面效果

    下面是一個基本的例子,展示了如何使用CSS和HTML實現(xiàn)一個3D頁面翻轉(zhuǎn)效果: HTML部分: CSS部分: 在這個例子中,我們使用一個包含兩個面(正面和背面)的容器div。通過CSS的 transform 屬性和 rotateY 函數(shù),我們實現(xiàn)了容器在鼠標懸停時的旋轉(zhuǎn)效果。 你可以根據(jù)自己的需求調(diào)整容

    2024年01月24日
    瀏覽(35)
  • CSS打造圖片翻轉(zhuǎn)立體3D效果

    CSS打造圖片翻轉(zhuǎn)立體3D效果

    ? html的結(jié)構(gòu)非常簡單,只要一個盒子里面放二張照片即可 html代碼: css代碼: 這里記得開絕對定位時一定要給父盒子開啟相對定位,否則圖片就會以body為父盒子進行定位了 我們可以通過 transform 這個css屬性對樣式進行一些翻轉(zhuǎn)處理 1.我們需要翻轉(zhuǎn)第一張圖片展示第二張圖片

    2024年02月07日
    瀏覽(22)
  • unity 利用Graphics.Blit來制作圖片效果

    c# 的代碼 source可以是當(dāng)前相機的RenderTexture也可以是準備好的一張圖,然后利用material提供的效果將效果輸出到renderTexture,第三個參數(shù)是使用哪個pass 0表示是使用第一個 下面是例子對應(yīng)的shader,是一個模糊效果

    2024年01月21日
    瀏覽(26)
  • Three.js--》實現(xiàn)圖片轉(zhuǎn)3D效果展示

    Three.js--》實現(xiàn)圖片轉(zhuǎn)3D效果展示

    目錄 項目搭建 初始化three.js基礎(chǔ)代碼 加載圖片紋理 設(shè)置著色器 今天簡單實現(xiàn)一個three.js的小Demo,加強自己對three知識的掌握與學(xué)習(xí),只有在項目中才能靈活將所學(xué)知識運用起來,話不多說直接開始。 項目搭建 本案例還是借助框架書寫three項目,借用vite構(gòu)建工具搭建vue項目

    2024年02月08日
    瀏覽(88)
  • CSS3實現(xiàn)圖片的3D旋轉(zhuǎn)效果

    CSS3實現(xiàn)圖片的3D旋轉(zhuǎn)效果

    準備兩張圖片,尺寸一樣大,本代碼中是繞 Y 軸進行旋轉(zhuǎn)(也可以改為 X 軸)。 先看看效果: ? 代碼如下:

    2024年02月12日
    瀏覽(29)
  • Cesium中的流光道路效果 - 創(chuàng)建令人驚嘆的3D動態(tài)效果

    Cesium是一個強大的地理信息系統(tǒng)(GIS)開發(fā)平臺,提供了許多令人驚嘆的功能集,其中包括創(chuàng)建流光道路效果。這種效果可以為地圖添加動態(tài)的路徑效果,使用戶可以更好地理解地理數(shù)據(jù)的關(guān)系和變化。在本文中,我們將探討如何使用Cesium創(chuàng)建流光道路效果,并提供相應(yīng)的源

    2024年02月04日
    瀏覽(76)
  • 利用js實現(xiàn)matrix3d繞球旋轉(zhuǎn)效果

    利用js實現(xiàn)matrix3d繞球旋轉(zhuǎn)效果

    小球圍成一圈,繞中心軸旋轉(zhuǎn)

    2024年02月08日
    瀏覽(19)
  • 分享一個CSS的垂簾效果

    分享一個CSS的垂簾效果

    前些天發(fā)現(xiàn)了一個巨牛的人工智能學(xué)習(xí)網(wǎng)站,通俗易懂,風(fēng)趣幽默,忍不住分享一下給大家。點擊跳轉(zhuǎn)到網(wǎng)站。 先上效果圖: 再上代碼: 代碼直接粘貼到html頁面就能使用,順滑的不可言說

    2024年02月01日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包