Jump to content

Extension:3DAlloy

From mediawiki.org
This page is a translated version of the page Extension:3DAlloy and the translation is 28% complete.
MediaWiki扩展手册
3DAlloy
发行状态: 稳定版
实现 解析器函数 , 标签 , ContentHandler , 链接标记
描述 Adds an interactive viewer of 3D models to MediaWiki
作者 Dolfinus
最新版本 1.10 (2025-10-27)
MediaWiki >= 1.43
数据库更改
$wg3DAlloy
‎<3d>
许可证 MIT License
下載 (for MW 1.33 and below use mw-1.33 branch)
README
示例 Example of 3D Viewer at file page

描述

3DAlloy allows to add an interactive viewer for 3D models to wiki pages. Based on THREE.js, it renders images with CanvasRenderer. There you can see the example 3D model page.

支持的文件扩展名

THREE.js模型格式:

  • .json
  • .3djson
  • .3dj
  • .three

THREE.js model buffer geometry format:

  • .buff
  • .buffjson

OBJ文件格式:

  • .obj

STL (binary) file format:

  • .stl
  • .stlb


安裝

$wgFileExtensions = array_merge(
  $wgFileExtensions, array(
      'json', '3dj', '3djson', 'three',
      'buff', 'buffjson',
      'obj',
      'stl', 'stlb'
  )
);
  • Yes 完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。

用法

As Image Handler

[[File:Model.json|300x300px|color=,opacity=,...]]

As Parser function

{{#3d:Model.json}}
{{#3d:Model.json|width}}
{{#3d:Model.json|width|height}}
...
{{#3d:Model.json|width|height|color|opacity|zoom|pan|norotate|scale|z|style|class}}

Instead of a filename you can also use a URL for a file located in a external site.

As Parser tag

<3d file="Model.json" width="" height="" ... ></3d>

or

<3d width="" height="" ... >Model.json</3d>

You also can use a URL instead of a filename.

Parameters

名称 描述 Default value
width Canvas width in pixels 300
height Canvas height in pixels 300
color Model RGB color as hex 0xff00ff
opacity Model opacity as decimal between 0...1 0.8
zoom If true or 1, canvas can be zoomed false
pan If true or 1, canvas can be panned false
norotate If true or 1, model does not rotate false
scale Model scale as decimal between 0...1 1
z Model z coordinate 75
style Additional canvas CSS style
class Additional canvas HTML class

If width and height are both 0, viewer size will be set according to screen dimensions.

配置

All default values can be changed in your LocalSettings.php file:

$wg3DAlloy["width"]  = 500;
$wg3DAlloy["height"] = 400;
...
$wg3DAlloy["class"]  = 'someclass';

Controls and hotkeys

Hotkeys are automatically disabled while you edit or submit a wiki page.

操作 控制
Camera rotate Swipe, left mouse key hold and move
Camera zoom (if zoom enabled) Mouse wheel, hold wheel and move, pinch
Camera pan (if pan enabled) Right key hold and move
Model rotate ←↑→↓键
Model rotation reset Home键
Model rotation play/pause 双击、双点按
Model rotation play/pause all models at page 回车、空格键
Model rotation speed -和+键