小编Ann*_*a_B的帖子

三.js:如何正确添加envMap?

我正在寻找像这样的材料: https ://thirdjs.org/examples/#webgl_materials_envmaps_exr

所以我会这样尝试:

* {
margin: 0;
padding: 0;
}

.object {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
pointer-events: none;
background-color: rgb(200, 200, 200);
}
Run Code Online (Sandbox Code Playgroud)
<script type="module">
import * as THREE from "https://threejs.org/build/three.module.js";

import { OBJLoader } from "https://threejs.org/examples/jsm/loaders/OBJLoader.js";

var container;

var camera, scene, renderer;

var mouseX = 0,
    mouseY = 0;

var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;

var object;

init();
animate();

function init() {
    container = document.createElement("div");
    container.className …
Run Code Online (Sandbox Code Playgroud)

javascript three.js

5
推荐指数
1
解决办法
1万
查看次数

Intersection Observer针对不同窗口大小进行微调

到目前为止,这是我的代码:

const mediaInViewport = document.querySelectorAll('.media');
const links = Array.from(document.querySelectorAll('.link'));
let actLink = links[0];

document.body.addEventListener('click', (event) => {
  if (event.target.tagName === 'a') {
    actLink.classList.remove('active');
    actLink = links.find(link => event.target.href === link.href)
    actLink.classList.add('active');
  }
}, false)

observer = new IntersectionObserver((entries, observer) => {
  entries.forEach((entry) => {
    if (entry.target && entry.isIntersecting) {
      const closestParent = entry.target.closest('section');
      if (closestParent) {
        actLink.classList.remove('active');
        actLink = links.find(link =>
          link.href.slice(link.href.lastIndexOf('#')) === `#${closestParent.id}`
        )
        actLink.classList.add('active');
      }
    }
  });
}, {
  threshold: 0
});

window.addEventListener('DOMContentLoaded', () => {
  setTimeout( // …
Run Code Online (Sandbox Code Playgroud)

javascript intersection intersection-observer

5
推荐指数
1
解决办法
1208
查看次数

如何准确获得虚构文本内容宽度的边距?

这是我正在处理的列表:

\n

\r\n
\r\n
* {\n  margin: 0;\n  padding: 0;\n  font-family: Arial;\n}\n\nol {\n  counter-reset: item;\n}\n\nli {\n  display: block;\n}\n\nli:before {\n  content: counters(item, ".") "\xe2\x80\x83";\n  counter-increment: item;\n}\n\nol li ol li {\n  margin-left: 80px; /* The left margin should have exactly the width of one number and a &emsp; */\n}
Run Code Online (Sandbox Code Playgroud)\r\n
<ol>\n  <li>Coffee\n    <ol>\n      <li>One</li>\n      <li>Two</li>\n      <li>Three</li>\n    </ol>\n  </li>\n  <li>Tea\n    <ol>\n      <li>One</li>\n      <li>Two</li>\n      <li>Three</li>\n    </ol>\n  </li>\n  <li>Milk</li>\n  <li>Cool</li>\n</ol>
Run Code Online (Sandbox Code Playgroud)\r\n
\r\n
\r\n

\n

目前ol li ol limargin-left: 80px;. 现在可以手动调整该px …

css

5
推荐指数
1
解决办法
78
查看次数

带有 Matter.js 的 HTML 元素

我愿与Matter.js像的方式移动HTML元素

这些是我的对象:

div {
  color: white;
  font-size: 70px;
  padding: 20px;
  display: inline-block;
  font-family: Arial;
  background: azure;
}

.canvas {
  width: 500px;
  height: 500px;
}

.object-one {
  background: blue;
}

.object-two {
  background: red;
}

.object-three {
  background: green;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://raw.githubusercontent.com/liabru/matter-js/master/build/matter.js"></script>

<div class="canvas">

  <div class="object-one">One</div>
  <div class="object-two">Two</div>
  <div class="object-three">Three</div>

</div>
Run Code Online (Sandbox Code Playgroud)

一般来说有可能吗?有人可以帮我吗?:)

javascript dom matter.js

1
推荐指数
1
解决办法
683
查看次数

如何使用“object-fit:contain;”在图像上获得框阴影?

我想与此合作:

img {
  width: 200px;
  height: 300px;
  object-fit: contain;
  box-shadow: 0 0 30px red, 0 0 30px red;
}
Run Code Online (Sandbox Code Playgroud)
<div>
  <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Felis_catus-cat_on_snow.jpg/220px-Felis_catus-cat_on_snow.jpg">
</div>
Run Code Online (Sandbox Code Playgroud)

box-shadow应该直接在图像上,而不是在图像容器的边界上。我已经尝试过drop-shadow(),但后来我无法添加两次效果。还有其他方法可以解决这个问题吗?

css

1
推荐指数
1
解决办法
716
查看次数